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]

qq = []
i = 0
while i < N-1:
  if q[i] + q[i+1] == 0:
    qq += [1]
    i += 2
    ans += 1
  elif q[i] == 0:
    qq += [0]
    i += 1
  elif q[i] == 1:
    qq += [1]
    i += 1

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