N = int(input())
p = list(map(int, input().split()))
ans = 0
q = []
for i in range(N):
  if i+1 == p[i]:
    q += [0]
  else:
    q += [1]

for i in range(N-1):
  if (q[i+1] == 1 and q[i] == 0):
    ans += 1
    q[i] = 1
  elif (q[i+1] == 0 and q[i] == 1):
    ans += 1
    q[i+1] = 1
  elif q[i+1] == 0 and q[i] == 0:
    ans += 1
    q[i+1] = 1
    q[i] = 1
print(ans)
  