program prob4
    implicit none
    integer::N, i, ans, cnt
    integer, allocatable::p(:)
    read(*,*) N
    allocate(p(N))
    read(*,*) p

    ans = 0
    cnt = 0
    do i = 1, N
        if(p(i) == i) then
            cnt = cnt + 1
        else
            ans = ans + (cnt+1)/2
            cnt = 0
        end if
    end do
    ans = ans + (cnt+1)/2
    write(*,*) ans
    deallocate(p)
    stop
end program