S = eval(input())



N = len(S)

a,z = 0,0

for i in range(N):

    if S[i]=="A":

        a = i

        break

for i in range(N):

    if S[N-1-i]=="Z":

        z = N-1-i

        break



print((z-a+1))
# python3 (3.4.3)

import sys

input = sys.stdin.readline



# main

S = input().rstrip()



ai = S.find("A")

zi = S.rfind("Z")



print((zi-ai+1))
S = eval(input())
N = len(S)
a, z = 0, 0
for i in range(N):
    if S[i] == "A":
        a = i
        break
for i in range(N):
    if S[N - 1 - i] == "Z":
        z = N - 1 - i
        break
print((z - a + 1))

# python3 (3.4.3)
import sys

input = sys.stdin.readline
# main
S = input().rstrip()
ai = S.find("A")
zi = S.rfind("Z")
print((zi - ai + 1))

-S = eval(input()) -N = len(S) -a, z = 0, 0 -for i in range(N): -    if S[i] == "A": -        a = i -        break -for i in range(N): -    if S[N - 1 - i] == "Z": -        z = N - 1 - i -        break -print((z - a + 1)) +# python3 (3.4.3) +import sys + +input = sys.stdin.readline +# main +S = input().rstrip() +ai = S.find("A") +zi = S.rfind("Z") +print((zi - ai + 1))