import qualified Data.ByteString.Char8 as BS

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

