program prob4
    implicit none
    integer::N, i, ans
    integer, allocatable::p(:)
    read(*,*) N
    allocate(p(N))
    read(*,*) p
    ans = 0
    do i = 2, N
        if(i > 1 .and. p(i) == i .and. p(i-1) == i) then
            ans = ans + 1
        else if(p(i) == i) then
            ans = ans + 1
        end if
    end do
    if(p(1) == 1 .and. p(2) /= 2) then
        ans = ans + 1
    end if
    write(*,*) ans
    deallocate(p)
    stop
end program