program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans,cnt
    integer(int32), allocatable:: p(:)

    read*, n
    allocate(p(n))
    read*, p

    ans=0
    do i=1,n
        if (p(i) == i) ans=ans+1
    end do

    cnt=1
    do i=2,n
        if (p(i) == i .and. p(i-1) == i-1) then
            cnt=cnt+1
        else
            ans=ans-cnt/2
            cnt=1
        end if
    end do
    ans=ans-cnt/2
    print'(i0)', ans
end program name