let () = 
  let s = read_line () in
  let head =
    Array.init (String.length s) (fun i -> i)
    |> Array.to_list
    |> List.filter (fun i -> s.[i] = 'A')
    |> List.hd in
  let tail = 
    Array.init (String.length s) (fun i -> i)
    |> Array.to_list
    |> List.filter (fun i -> s.[i] = 'Z')
    |> List.rev
    |> List.hd in
  Printf.printf "%d\n" @@ tail - head + 1
