# 入力

s = eval(input())



# 処理

left_A  = -1  # 最も左のAの位置

right_Z = -1  # 最も右のZの位置



for i in range(len(s)):

  # left_A < 0 => まだAを見つけていない

  if left_A < 0 and s[i] == "A":

    left_A = i

  if s[i] == "Z":

    right_Z = i



# 答え

print((right_Z - left_A + 1))
s = eval(input())

left = 0

right = len(s)-1

for i in range(len(s)):

    if s[i] == "A":

        left = i

        break

for i in range(len(s)-1,0,-1):

    if s[i] == "Z":

        right = i

        break

print((right-left+1))

# 入力
s = eval(input())
# 処理
left_A = -1  # 最も左のAの位置
right_Z = -1  # 最も右のZの位置
for i in range(len(s)):
    # left_A < 0 => まだAを見つけていない
    if left_A < 0 and s[i] == "A":
        left_A = i
    if s[i] == "Z":
        right_Z = i
# 答え
print((right_Z - left_A + 1))

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

-# 入力 -# 処理 -left_A = -1  # 最も左のAの位置 -right_Z = -1  # 最も右のZの位置 +left = 0 +right = len(s) - 1 -    # left_A < 0 => まだAを見つけていない -    if left_A < 0 and s[i] == "A": -        left_A = i +    if s[i] == "A": +        left = i +        break +for i in range(len(s) - 1, 0, -1): -        right_Z = i -# 答え -print((right_Z - left_A + 1)) +        right = i +        break +print((right - left + 1))