s=eval(input())

p=0

q=0

r=0

m=0

for i in s:

  r +=1

  if i =='A':

    if p==0:

      p=r

  elif p!=0 and i=='Z':

    q = r

print((q-p+1))
s = str(eval(input()))

N = len(s)

for i in range(N):

  if s[i] =='A':

    break

for j in range(1,N):

  if s[-j] =='Z':

    break

print((N-i-j+1))
s = eval(input())
p = 0
q = 0
r = 0
m = 0
for i in s:
    r += 1
    if i == "A":
        if p == 0:
            p = r
    elif p != 0 and i == "Z":
        q = r
print((q - p + 1))

s = str(eval(input()))
N = len(s)
for i in range(N):
    if s[i] == "A":
        break
for j in range(1, N):
    if s[-j] == "Z":
        break
print((N - i - j + 1))

-s = eval(input()) -p = 0 -q = 0 -r = 0 -m = 0 -for i in s: -    r += 1 -    if i == "A": -        if p == 0: -            p = r -    elif p != 0 and i == "Z": -        q = r -print((q - p + 1)) +s = str(eval(input())) +N = len(s) +for i in range(N): +    if s[i] == "A": +        break +for j in range(1, N): +    if s[-j] == "Z": +        break +print((N - i - j + 1))