import Data.List
import Data.Maybe

find_last f xs
    | i /= Nothing = find_last f $ drop (fromJust i + 1) xs
    | i == Nothing = length xs
    where
        i = findIndex f xs

main = do
    s <- getLine
    print $ length s - (find_last (\x -> x == 'Z') s) - fromJust (findIndex (\x -> x == 'A') s)