S = list(eval(input()))

count = 0

for i in range(len(S)):

    if (S[i] == "A") and (count == 0):

        start = i

        count = 1

    if S[i] == "Z":

        end = i

print((end - start + 1))

s = eval(input())

start = s.find("A")

end = s.rfind("Z")

print((end - start + 1))
S = list(eval(input()))
count = 0
for i in range(len(S)):
    if (S[i] == "A") and (count == 0):
        start = i
        count = 1
    if S[i] == "Z":
        end = i
print((end - start + 1))

s = eval(input())
start = s.find("A")
end = s.rfind("Z")
print((end - start + 1))

-S = list(eval(input())) -count = 0 -for i in range(len(S)): -    if (S[i] == "A") and (count == 0): -        start = i -        count = 1 -    if S[i] == "Z": -        end = i +s = eval(input()) +start = s.find("A") +end = s.rfind("Z")