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

change = []
count = 0
for i in range(N):
  if(i+1 == A[i]): change.append(i+1)

ans = 0
for i in range(len(change)):
  if(i%2 == 1): #偶数個目の要素について
    ans += change[i]-change[i-1]
if(len(change)%2 == 1): ans += 1
print(ans)