import           Control.Monad
import           Control.Applicative
import           Data.IORef
import           Data.List.Split
import           Data.Maybe
import           Data.List

main :: IO ()
main = do
  s <- getLine
  print $ last (elemIndices 'Z' s) - head (elemIndices 'A' s) + 1