program prob1
    implicit none
    integer :: n
    integer :: a, b
    integer :: i
    character(200005) :: s
    read(*,*) s
    n = len_trim(s)
    do i = 1, n
        if(s(i:i) == 'A') then
            a = i
        end if
        if(s(n-i+1:n-i+1) == 'Z') then
            b = n-i+1
        end if
    end do
    write(*,*) b-a+1


    stop
contains
end program prob1