s = list(eval(input()))



A = s.index("A")



S = list(reversed(s))

Z = S.index("Z")



print((len(s) - Z - A))

s = list(eval(input()))



for i in range(len(s)):

    if s[i] == "A":

        A = i

        break

for i in range(len(s)):

    if s[i] == "Z" and i > A:

        B = i



    

print((B - A + 1))
s = list(eval(input()))
A = s.index("A")
S = list(reversed(s))
Z = S.index("Z")
print((len(s) - Z - A))

s = list(eval(input()))
for i in range(len(s)):
    if s[i] == "A":
        A = i
        break
for i in range(len(s)):
    if s[i] == "Z" and i > A:
        B = i
print((B - A + 1))

-A = s.index("A") -S = list(reversed(s)) -Z = S.index("Z") -print((len(s) - Z - A)) +for i in range(len(s)): +    if s[i] == "A": +        A = i +        break +for i in range(len(s)): +    if s[i] == "Z" and i > A: +        B = i +print((B - A + 1))