program main
  implicit none
  integer :: n, i, res
  integer, allocatable :: p(:)
  read (*, *) n
  allocate (p(n))
  read (*, *) p
  i = 1
  res = 0
  do while (i <= n)
    if (p(i) == i) then
      res = res + 1
      i = i + 2
    else
      i = i + 1
    end if
  end do
  write (*, "(i0)") res
end program main
