N = int(input())
p = list(map(int, input().split()))

c = 0
m = 0
box = []
for i in range(N):
  if p[i] - 1 == i:
    c += 1
    box.append(i)
    if len(box) >= 2 and box[-2] + 1 == box[-1]:
      m += 1
print(c-m)