S=list(eval(input()))

N=len(S)

pos_Z=N-S[::-1].index("Z")

pos_A=S.index("A")

print((pos_Z-pos_A))
S=eval(input())

print((S.rfind("Z")-S.find("A")+1))
S = list(eval(input()))
N = len(S)
pos_Z = N - S[::-1].index("Z")
pos_A = S.index("A")
print((pos_Z - pos_A))

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

-S = list(eval(input())) -N = len(S) -pos_Z = N - S[::-1].index("Z") -pos_A = S.index("A") -print((pos_Z - pos_A)) +S = eval(input()) +print((S.rfind("Z") - S.find("A") + 1))