import Data.List
import Data.Maybe

main :: IO ()
main = do
    line <- getLine
    -- let line = "AZZ"
    putStrLn $ solve line

solve :: String -> String
solve s = show $ len - indA - indZ'
    where
        len = length s
        indA = fromJust $ elemIndex 'A' s
        indZ' = fromJust $ elemIndex 'Z' $ reverse s
