N = gets.to_i
PS = gets.chomp.split.map(&:to_i)

MAX = 10**5 + 1
m = Array.new(MAX, false)

PS.each_with_index do |p, i|
  m[i] = p if p == i+1
end

count = 0
MAX.times do |i|
  next unless m[i]
  if PS[i+1] != i && m[i] != i+1
    PS[i+1], m[i] = m[i], PS[i+1]
    count += 1
  elsif PS[i-1] != i && m[i] != i-1
    PS[i-1], m[i] = m[i], PS[i-1]
    count += 1
  end
end
p count