n = gets.to_i
p = gets.split.map(&:to_i)

n_swap = 0
for i in 0 ... n-1  do
  if p[i] == i+1
    p[i], p[i+1] = p[i+1], p[i]
    n_swap += 1
  end
end
if p[p.size-1] = p.size
  p[p.size-2], p[p.size-1] = p[p.size-1], p[p.size-2]
  n_swap += 1
end
puts n_swap