S = list(eval(input()))

st = len(S)

ed = 0

for i in range(len(S)):

    if (S[i] == 'A'):

        st = min(i, st)

    if (S[i] == 'Z'):

        ed = i

ans = ed - st + 1

print(ans)
s = eval(input())

p = -1

for i in range(len(s)) :

    if s[i] == 'A' and p == -1:

        p = i

    if s[i] == 'Z':

        q = i

print((q - p + 1))



    

S = list(eval(input()))
st = len(S)
ed = 0
for i in range(len(S)):
    if S[i] == "A":
        st = min(i, st)
    if S[i] == "Z":
        ed = i
ans = ed - st + 1
print(ans)

s = eval(input())
p = -1
for i in range(len(s)):
    if s[i] == "A" and p == -1:
        p = i
    if s[i] == "Z":
        q = i
print((q - p + 1))

-S = list(eval(input())) -st = len(S) -ed = 0 -for i in range(len(S)): -    if S[i] == "A": -        st = min(i, st) -    if S[i] == "Z": -        ed = i -ans = ed - st + 1 -print(ans) +s = eval(input()) +p = -1 +for i in range(len(s)): +    if s[i] == "A" and p == -1: +        p = i +    if s[i] == "Z": +        q = i +print((q - p + 1))