s=list(eval(input()))



As=[i for i, x in enumerate(s) if x == 'A']

Zs=[i for i, x in enumerate(s) if x == 'Z']

print((Zs[-1]-As[0]+1))

s = eval(input())

n = len(s)

for i in range(n):

    if s[i] == 'A':

        start = i

        break

for i in range(n):

    if s[i] == 'Z':

        end = i

print((end-start+1))
s = list(eval(input()))
As = [i for i, x in enumerate(s) if x == "A"]
Zs = [i for i, x in enumerate(s) if x == "Z"]
print((Zs[-1] - As[0] + 1))

s = eval(input())
n = len(s)
for i in range(n):
    if s[i] == "A":
        start = i
        break
for i in range(n):
    if s[i] == "Z":
        end = i
print((end - start + 1))

-s = list(eval(input())) -As = [i for i, x in enumerate(s) if x == "A"] -Zs = [i for i, x in enumerate(s) if x == "Z"] -print((Zs[-1] - As[0] + 1)) +s = eval(input()) +n = len(s) +for i in range(n): +    if s[i] == "A": +        start = i +        break +for i in range(n): +    if s[i] == "Z": +        end = i +print((end - start + 1))