program sample
    implicit none
  
    integer(8) :: i,j,m,n,a
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    a=0
    m=0
    do i=1,n
        if(x(i)==i)then
            if(a==0)then
                a=1
            else
                a=0
                m=m+1
            end if
        elseif(a==1)then
            a=0
            m=m+1
        end if
    end do

            
    write(*,*) m
  
    stop
end program sample
  

