
rsolve (x:xs) =
  if x == 'Z'
    then x:xs
    else rsolve xs

solve (x:xs) =
  if x == 'A'
    then x:xs
    else solve xs

main = do
  line <- getLine
  putStrLn $ show . length $ rsolve . reverse $ solve line
