import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
    s <- getLine
    print $ (length s) - (f (elemIndex 'Z' (reverse s))) - (f (elemIndex 'A' s))

f :: Maybe Int -> Int
f (Just n) = n
f Nothing  = 0