s = eval(input())

ca = []

cz = []

ans = 0

for i in range(len(s)):

    if s[i] == "A":

        ca.append(i)

    if s[i] == "Z":

        cz.append(i)

ans = max(cz)-min(ca)+1

print(ans)

s = eval(input())



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

s = eval(input())
ca = []
cz = []
ans = 0
for i in range(len(s)):
    if s[i] == "A":
        ca.append(i)
    if s[i] == "Z":
        cz.append(i)
ans = max(cz) - min(ca) + 1
print(ans)

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

-ca = [] -cz = [] -ans = 0 -for i in range(len(s)): -    if s[i] == "A": -        ca.append(i) -    if s[i] == "Z": -        cz.append(i) -ans = max(cz) - min(ca) + 1 -print(ans) +print((s.rfind("Z") - s.find("A") + 1))