program prob2
    implicit none
    character(len=200005)::s
    integer::i, l, r, p
    read(*,*) s
    p = 0
    do i = 1, len_trim(s)
        if(s(i:i) .eq. 'A' .and. p == 0) then
            l = i
            p = 1
        end if
        if(s(i:i) .eq. 'Z') r = i
    end do
    write(*,*) r - l + 1
    stop
end program