s = eval(input())

ans = []

for i in range(len(s)):

    if s[i] == "A":

        j = i

        break

for i in range(len(s)):

    if s[len(s)-i-1] == "Z":

        k = len(s)-i-1

        break

ans = k-j+1

print(ans)
string = eval(input())

index = -1

for i in range(len(string)): 

        if string[i] == "Z": 

            index = i 

w = string.index("A")

z = string[w:index+1]

print((len(z)))
s = eval(input())
ans = []
for i in range(len(s)):
    if s[i] == "A":
        j = i
        break
for i in range(len(s)):
    if s[len(s) - i - 1] == "Z":
        k = len(s) - i - 1
        break
ans = k - j + 1
print(ans)

string = eval(input())
index = -1
for i in range(len(string)):
    if string[i] == "Z":
        index = i
w = string.index("A")
z = string[w : index + 1]
print((len(z)))

-s = eval(input()) -ans = [] -for i in range(len(s)): -    if s[i] == "A": -        j = i -        break -for i in range(len(s)): -    if s[len(s) - i - 1] == "Z": -        k = len(s) - i - 1 -        break -ans = k - j + 1 -print(ans) +string = eval(input()) +index = -1 +for i in range(len(string)): +    if string[i] == "Z": +        index = i +w = string.index("A") +z = string[w : index + 1] +print((len(z)))