from collections import deque

s=eval(input())



ds=deque(s)

flag=True



while ds[0]!='A' or ds[-1]!='Z':

  if ds[0]!='A':

    ds.popleft()

  if ds[-1]!='Z':

    ds.pop()

print((len(ds)))
s=eval(input())

 

ds=list(s)

 

 

c1=0

while ds[c1]!='A':

  c1+=1

 

c2=-1

while ds[c2]!='Z':

  c2-=1

 

print((len(s[c1:c2])+1))
from collections import deque

s = eval(input())
ds = deque(s)
flag = True
while ds[0] != "A" or ds[-1] != "Z":
    if ds[0] != "A":
        ds.popleft()
    if ds[-1] != "Z":
        ds.pop()
print((len(ds)))

s = eval(input())
ds = list(s)
c1 = 0
while ds[c1] != "A":
    c1 += 1
c2 = -1
while ds[c2] != "Z":
    c2 -= 1
print((len(s[c1:c2]) + 1))

-from collections import deque - -ds = deque(s) -flag = True -while ds[0] != "A" or ds[-1] != "Z": -    if ds[0] != "A": -        ds.popleft() -    if ds[-1] != "Z": -        ds.pop() -print((len(ds))) +ds = list(s) +c1 = 0 +while ds[c1] != "A": +    c1 += 1 +c2 = -1 +while ds[c2] != "Z": +    c2 -= 1 +print((len(s[c1:c2]) + 1))