let s = read_line ();;
let slen = String.length s;;

let rec loop1 i en = 
    if i == slen
    then 
        en
    else
        match s.[i] with
            |'Z' -> loop1 (i+1) i
            |_ -> loop1 (i+1) en;;

let rec loop2 i = 
    match s.[i] with
    |'A' -> i,loop1 i 0
    |_ -> loop2 (i+1);;


let (st,en) = loop2 0
    in
        Printf.printf "%s\n" (String.sub s st (en-st+1)) ;;