main :: IO()
main = do
    str <- getLine
    print $ (length str) - (searchA str) - (searchZ str)
    

searchA :: String -> Int
searchA str
    | head str == 'A'		= 0
    | otherwise				= 1 + searchA (tail str)

searchZ :: String -> Int
searchZ str
    | last str == 'Z'		= 0
    | otherwise				= 1 + searchZ (init str)





