s = eval(input())



rs  = s[::-1]



inds = 0

indrs = 0



for i in range(len(s)):

    if s[i] == "A":

        inds = i

        break

    

for j in range(len(rs)):

    if rs[j] == "Z":

        indrs = j

        break



indrs = len(s) - indrs



print((abs(indrs - inds)))

s = eval(input())



left = s.find("A")

right = s.rfind("Z")



print((right - left + 1))
s = eval(input())
rs = s[::-1]
inds = 0
indrs = 0
for i in range(len(s)):
    if s[i] == "A":
        inds = i
        break
for j in range(len(rs)):
    if rs[j] == "Z":
        indrs = j
        break
indrs = len(s) - indrs
print((abs(indrs - inds)))

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

-rs = s[::-1] -inds = 0 -indrs = 0 -for i in range(len(s)): -    if s[i] == "A": -        inds = i -        break -for j in range(len(rs)): -    if rs[j] == "Z": -        indrs = j -        break -indrs = len(s) - indrs -print((abs(indrs - inds))) +left = s.find("A") +right = s.rfind("Z") +print((right - left + 1))