s = eval(input())

l = 1000000

r = 0

for i, c in enumerate(s):

    if c == "A":

        l = min(l, i)

    if c == "Z":

        r = i

print((r - l + 1))
import re

s = eval(input())

ans = re.search("A.*Z", s).group()

print((len(ans)))
s = eval(input())
l = 1000000
r = 0
for i, c in enumerate(s):
    if c == "A":
        l = min(l, i)
    if c == "Z":
        r = i
print((r - l + 1))

import re

s = eval(input())
ans = re.search("A.*Z", s).group()
print((len(ans)))

+import re + -l = 1000000 -r = 0 -for i, c in enumerate(s): -    if c == "A": -        l = min(l, i) -    if c == "Z": -        r = i -print((r - l + 1)) +ans = re.search("A.*Z", s).group() +print((len(ans)))