S = eval(input())

A_index = [i for i in range(len(S)) if S[i] == "A"]

Z_index = [i for i in range(len(S)) if S[i] == "Z"]

print((len(S[A_index[0] : Z_index[-1] + 1])))
S = eval(input())



head = [i for i in range(0, len(S)) if S[i]=="A"]

tail = [i for i in range(0, len(S)) if S[i]=="Z"]



print((max(tail)-min(head)+1))
S = eval(input())
A_index = [i for i in range(len(S)) if S[i] == "A"]
Z_index = [i for i in range(len(S)) if S[i] == "Z"]
print((len(S[A_index[0] : Z_index[-1] + 1])))

S = eval(input())
head = [i for i in range(0, len(S)) if S[i] == "A"]
tail = [i for i in range(0, len(S)) if S[i] == "Z"]
print((max(tail) - min(head) + 1))

-A_index = [i for i in range(len(S)) if S[i] == "A"] -Z_index = [i for i in range(len(S)) if S[i] == "Z"] -print((len(S[A_index[0] : Z_index[-1] + 1]))) +head = [i for i in range(0, len(S)) if S[i] == "A"] +tail = [i for i in range(0, len(S)) if S[i] == "Z"] +print((max(tail) - min(head) + 1))