program answer
  implicit none
  integer(8) :: i, count1, count2, n
  character(len=200000) :: s
  read(*,*) s
  n=len_trim(s)
  do i = 1, N
     if(s(i:i)=='A') then
        count1=i
        exit
     end if
  end do

  do i = 1, N
     if(S(i:i)=='Z') then
        count2=i
     end if
  end do

  write(*,*) count2-count1+1
  stop
 end program answer