import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  s <- C.getLine
  print $ a2z s

a2z :: C.ByteString -> Int
a2z = C.length . C.dropWhile (/='Z') . C.reverse . C.dropWhile (/='A') 
