S = eval(input())

A = [ind for ind, x in enumerate(S) if x == 'A']

Z = [ind for ind, x in enumerate(S) if x == 'Z']

print((max(Z) - min(A) + 1))
s = eval(input())



for ind, i in enumerate(s):

    if i == 'A':

        num1 = ind

        break



for ind, i in enumerate(s):

    if i == 'Z':

        num2 = ind



print((num2 - num1 + 1))
S = eval(input())
A = [ind for ind, x in enumerate(S) if x == "A"]
Z = [ind for ind, x in enumerate(S) if x == "Z"]
print((max(Z) - min(A) + 1))

s = eval(input())
for ind, i in enumerate(s):
    if i == "A":
        num1 = ind
        break
for ind, i in enumerate(s):
    if i == "Z":
        num2 = ind
print((num2 - num1 + 1))

-S = eval(input()) -A = [ind for ind, x in enumerate(S) if x == "A"] -Z = [ind for ind, x in enumerate(S) if x == "Z"] -print((max(Z) - min(A) + 1)) +s = eval(input()) +for ind, i in enumerate(s): +    if i == "A": +        num1 = ind +        break +for ind, i in enumerate(s): +    if i == "Z": +        num2 = ind +print((num2 - num1 + 1))