N=int(input())
P=list(map(int,input().split()))
Q=[]

for i in range(N):
  Q.append(1 if P[i]==i+1 else 0)
#print(Q)

cnt=0
ans=0
for i in range(N):
  if Q[i]==1:
    cnt+=1
  else:
    ans+=cnt%2+cnt//2
    cnt=0
print(ans)