s = list(eval(input()))

a = 200000

z = 0

for i in range(len(s)):

    if s[i] == 'A' and a > i:

        a = i

    if s[i] == 'Z' and z < i:

        z = i

print((z - a + 1))
s = eval(input())

print((len(s)-s[::-1].index("Z")-s.index("A")))
s = list(eval(input()))
a = 200000
z = 0
for i in range(len(s)):
    if s[i] == "A" and a > i:
        a = i
    if s[i] == "Z" and z < i:
        z = i
print((z - a + 1))

s = eval(input())
print((len(s) - s[::-1].index("Z") - s.index("A")))

-s = list(eval(input())) -a = 200000 -z = 0 -for i in range(len(s)): -    if s[i] == "A" and a > i: -        a = i -    if s[i] == "Z" and z < i: -        z = i -print((z - a + 1)) +s = eval(input()) +print((len(s) - s[::-1].index("Z") - s.index("A")))