program ABC152C
    implicit none
    integer(8)::N,i
    integer(8)::result=1
    integer(8),allocatable,dimension(:)::P
    read(5,*)N
    allocate(P(N))
    read(5,*)(P(i),i=1,N)

    if(P(1)==1)then
        print'(i0)',result
    else
        do i=2,N
            if(P(i)<P(i-1))then
                result=result+1
            end if

            if(P(i)==1)then
                exit
            end if
        end do

        print'(i0)',result
    end if
end program ABC152C