import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  s <- getLine
  let numA = minimum $ elemIndices 'A' s
  let numZ = (+1) $maximum $ elemIndices 'Z' s
  print $ (drop numA .take numZ) s