S=eval(input())

left=0

while S[left]!='A':

    left+=1

right=len(S)-1

while S[right]!='Z':

    right-=1

print((right-left+1))

s=eval(input())

print((s.rfind('Z')-s.find('A')+1))

S = eval(input())
left = 0
while S[left] != "A":
    left += 1
right = len(S) - 1
while S[right] != "Z":
    right -= 1
print((right - left + 1))

s = eval(input())
print((s.rfind("Z") - s.find("A") + 1))

-S = eval(input()) -left = 0 -while S[left] != "A": -    left += 1 -right = len(S) - 1 -while S[right] != "Z": -    right -= 1 -print((right - left + 1)) +s = eval(input()) +print((s.rfind("Z") - s.find("A") + 1))