program sample
    implicit none
    character(2000000)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) s
    n=len_trim(s)
    do i=1,n
        if(s(i:i) .eq. 'A')then
            a=i
            exit
        end if
    end do
    do i=n,1,-1
        if(s(i:i) .eq. 'Z')then
            b=i
            exit
        end if
    enddo
    write(*,*)b-a+1
    stop
end program sample
  

