io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
ans=0
a.each_cons(2).with_index(1) do |aa,i|
  #can't use aa
  if n!=i && a[i-1]==i ||
    n==i && a[i]==i
    a[i-1],a[i]=a[i],a[i-1]
    ans+=1
  end
end
puts ans