import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  bs <- BS.getLine :: IO BS.ByteString
  let a = BS.dropWhile (/='A') bs
  let z = BS.dropWhile (/='Z') (BS.reverse a) 
  print $ BS.length z

