program ABC_053_B_AtoZString
    implicit none
	integer i, starts, ends
    character(200000) s
    read(*, *) s
    do i = 1, len_trim(s)
		if(s(i:i) == 'A') then
			starts = i
			exit
		end if
	end do
    do i = 1, len_trim(s)
		if(s(len_trim(s)+1-i:len_trim(s)+1-i) == 'Z') then
			ends = len_trim(s)+1-i
			exit
		end if
	end do
	write(*, *) ends - starts + 1
end program ABC_053_B_AtoZString