x=1e9

for j,i in enumerate(eval(input())):

 if i=='A':x=min(x,j)

 if i=='Z':y=j

print((y-x+1))
s=eval(input())

print((len(s)-s[::-1].find('Z')-s.find('A')))
x = 1e9
for j, i in enumerate(eval(input())):
    if i == "A":
        x = min(x, j)
    if i == "Z":
        y = j
print((y - x + 1))

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

-x = 1e9 -for j, i in enumerate(eval(input())): -    if i == "A": -        x = min(x, j) -    if i == "Z": -        y = j -print((y - x + 1)) +s = eval(input()) +print((len(s) - s[::-1].find("Z") - s.find("A")))