main :: IO ()
main = do
  str <- getLine
  putStrLn $ show $ function1 str

function1 :: String -> Int
function1 str = length $ function3 $ function2 str 

function2 :: String ->  String
function2 str = dropWhile (/= 'A') str

function3 :: String -> String
function3 = dropWhile (/= 'Z') . reverse 