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

s = ""
N.times do |i|
  
  s += p[i]-1 != i ? ?o : ?x
  
end

# p s

ans = 0
(0...N).each do |i|
  
  if s[i] == ?x
    s[i] = ?o
    s[i+1] = ?o
    ans += 1
  end
end

puts ans