import qualified Data.Text as T
import qualified Data.Text.IO as T

solve False t
    |T.head t =='A' = solve True (T.reverse t)
    |otherwise = solve False (T.drop 1 t)
solve True t
    |T.head t =='Z' = T.length t
    |otherwise = solve True (T.drop 1 t)



main = do
    n <- T.getLine
    print(solve False n)