S = list(eval(input()))

Z_max = [i for i, x in enumerate(S) if x == 'Z']

print((len(S[S.index('A'):max(Z_max)+1])))
S = list(eval(input()))

ind_A = S.index('A')

ind_Z = [index for index, x in enumerate(S) if x == 'Z']



print((ind_Z[-1]-ind_A+1))
S = list(eval(input()))
Z_max = [i for i, x in enumerate(S) if x == "Z"]
print((len(S[S.index("A") : max(Z_max) + 1])))

S = list(eval(input()))
ind_A = S.index("A")
ind_Z = [index for index, x in enumerate(S) if x == "Z"]
print((ind_Z[-1] - ind_A + 1))

-Z_max = [i for i, x in enumerate(S) if x == "Z"] -print((len(S[S.index("A") : max(Z_max) + 1]))) +ind_A = S.index("A") +ind_Z = [index for index, x in enumerate(S) if x == "Z"] +print((ind_Z[-1] - ind_A + 1))