import Control.Monad
import Data.List
import Data.Maybe (fromJust)

main=do
    s<-getLine
    let l = fromJust $ findIndex (=='A') s
    let r = (-) (length s).fromJust.findIndex (=='Z') $ reverse s
    print $ r-l