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
N.times do |i|
  
  if s[i] == ?x
    
    s[i] == ?o
    ans += 1
    
    if i-1 >= 0 && s[i-1] == ?x
      
      s[i-1] = ?o
      
    elsif i+1 <= N - 1 && s[i+1] == ?x
      
      s[i+1] = ?o
      
    elsif i+1 <= N - 1 
      
      s[i+1] = ?o
      
    else
      
      s[i-1] = ?o
      
    end
  end
      
end

puts ans