implicit none
character(200000) :: s
integer :: n,a,z,i
read *,s
n = len_trim(s)
do i = 1, n
   if (s(i:i) == 'A') then
      a = i
      exit
   endif
enddo
do i = n, 1, -1
   if (s(i:i) == 'Z') then
      z = i
      exit
   endif
enddo
print '(i0)',z-a+1
end