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

idx = []
n.times do |i|
  idx << i if i + 1 == p[i]
end

res = 0

while idx.size > 0
  cnt = 1
  cur = idx.shift
  while cur + 1 == idx[0] && idx.size > 0
    cnt += 1
    cur = idx.shift
  end
  if cnt > 1
    res += cnt - 1
  else
    res += 1
  end
end
puts res