n = int(input())
l = list(map(int, input().split()))
l = [x-1 for x in l]

m = []
for i in range(n):
  if l[i] == i:
    m.append(i)

if len(m) == 0:
  print(0)
  exit()

ans = 0
temp = 0
for i in range(len(m)):
  if i == 0:
    temp += 1
  else:
    if l[i-1]+1 != l[i]:
      if temp >= 2:
        ans += (temp - 1)
      else:
        ans += temp
      temp = 1
    else:
      temp += 1
else:
  if temp >= 2:
    ans += (temp - 1)
  else:
    ans += temp

print(ans)