program prob4
    implicit none
    integer :: tmp, N, i, ans
    integer, allocatable :: a(:)
    read(*,*) N
    allocate(a(N))
    read(*,*) a
    ans = 0
    do i = 1, N-1
        if(i == a(i))then
            tmp = a(i+1)
            a(i+1) = i
            a(i) = tmp
            ans = ans + 1
        end if
    end do
    if(N == a(N))then
        ans = ans + 1
    end if
    write(*,*) ans

    deallocate(a)

    stop
contains
end program prob4