s = eval(input())



st = None

en = None

for i in range(len(s)):

    if st is None and s[i] == 'A':

        st = i

    if en is None and s[-i-1] == 'Z':

        en = -i - 1

print((len(s[st:en]) + 1))
s = eval(input())



print((s.rindex('Z') - s.index('A') + 1))

s = eval(input())
st = None
en = None
for i in range(len(s)):
    if st is None and s[i] == "A":
        st = i
    if en is None and s[-i - 1] == "Z":
        en = -i - 1
print((len(s[st:en]) + 1))

s = eval(input())
print((s.rindex("Z") - s.index("A") + 1))

-st = None -en = None -for i in range(len(s)): -    if st is None and s[i] == "A": -        st = i -    if en is None and s[-i - 1] == "Z": -        en = -i - 1 -print((len(s[st:en]) + 1)) +print((s.rindex("Z") - s.index("A") + 1))