S = eval(input())

a = len(S)

z = 0

for i in range(len(S)):

    if S[i] == 'A':

        a = min(a,i)

    if S[i] == 'Z':

        z = max(z,i)

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

print((s.rfind('Z')-s.find('A')+1))
S = eval(input())
a = len(S)
z = 0
for i in range(len(S)):
    if S[i] == "A":
        a = min(a, i)
    if S[i] == "Z":
        z = max(z, i)
print((z - a + 1))

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

-S = eval(input()) -a = len(S) -z = 0 -for i in range(len(S)): -    if S[i] == "A": -        a = min(a, i) -    if S[i] == "Z": -        z = max(z, i) -print((z - a + 1)) +s = eval(input()) +print((s.rfind("Z") - s.find("A") + 1))