def swap(arr, idx0, idx1)
  arr[idx0], arr[idx1] = arr[idx1], arr[idx0]
end

def answer(arr)
  count = 0
  arr.size.times do |idx|
    num = arr[idx]
    next if num != idx + 1

    swap(
      arr,
      idx,
      (arr[idx + 1] == idx + 2) ? idx + 1 : idx - 1
    )
    count += 1
  end

  count
end

gets
puts answer(gets.split.map(&:to_i))