import Data.List
import Data.Maybe

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

solve :: String -> String
solve s = show $ indZ - indA + 1
    where
        indA = fromJust $ elemIndex 'A' s
        indZ = fromJust $ elemIndex 'Z' s