import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List as List

solve :: String -> Int
solve = length . (List.dropWhile (/= 'A')) . reverse . (List.dropWhile (/= 'Z')) . reverse

main :: IO()
main = do
    s <- getLine
    print $ solve s
