import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    xs <- getLine
    let ans = reverse . dropWhile (/= 'Z') . reverse $ dropWhile (/= 'A') xs
    print $ length ans