import qualified Data.ByteString.Char8 as BS
fa [] n = 0
fa (x:xs) n =if x=='A' then n else f xs n+1
fz [] n = 0
fz s n =if last s=='Z' then n else fz (init s) n-1
main=do
 s<-BS.getLine
 let l=BS.length s
 print$fz s l-fa s 1+1