program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,l=0,r,m
    character(100):: na, ma

    read*, n
    print'(i0)', 0
    read*, na
    r = n-1

    do while(r-l>1)
        m = (l+r)/2
        print'(i0)', m
        read*, ma
        if (btest(m,0) .eqv. ma == na) then
            r = m
        else
            l = m
        end if
    end do
    print'(i0)', r
end program main