s = eval(input())

a = s.find('A')

z = s[::-1].find('Z')

ans = len(s)-a-z



print(ans)



#print(*ans, sep='\n')
def solve():

  S = eval(input())

  a = S.find('A')

  z = S[::-1].find('Z')

  ans = len(S)-a-z

  return ans

print((solve()))
s = eval(input())
a = s.find("A")
z = s[::-1].find("Z")
ans = len(s) - a - z
print(ans)
# print(*ans, sep='\n')

def solve():
    S = eval(input())
    a = S.find("A")
    z = S[::-1].find("Z")
    ans = len(S) - a - z
    return ans


print((solve()))

-s = eval(input()) -a = s.find("A") -z = s[::-1].find("Z") -ans = len(s) - a - z -print(ans) -# print(*ans, sep='\n') +def solve(): +    S = eval(input()) +    a = S.find("A") +    z = S[::-1].find("Z") +    ans = len(S) - a - z +    return ans + + +print((solve()))