gets

count = 0
arr = gets.split.map(&:to_i)
arr.size.times do |idx|
  num = arr[idx]
  next if num != idx + 1

  if idx - 1 >= 0 && (b_num = arr[idx - 1]) && b_num != idx
    arr[idx] = b_num
    arr[idx - 1] = num
    count += 1
  elsif (a_num = arr[idx + 1]) && a_num != idx
    arr[idx] = a_num
    arr[idx + 1] = num
    count += 1
  else
    raise arr.inspect
  end
end

puts count