program main
  implicit none
  integer :: n, i, a, z
  character(200000) :: s
  read (*, *) s
  n = len_trim(s)
  do i = 1, n
    if (s(i:i) == "A") then
      a = i
      exit
    end if
  end do
  do i = 1, n
    if (s(i:i) == "Z") z = i
  end do
  write (*, "(i0)") z - a + 1
end program main
