n=int(input())
p=[int(i) for i in input().split()]
cnt=0
for i in range(n):
		if p[i]==i+1:
			if p[i]!=i and i!=0:
				pi=p[i]
				p[i]=p[i-1]
				p[i-1]=pi
				cnt+=1
			elif p[i]!=i+2 and i!=n-1:
				pi=p[i]
				p[i]=p[i+1]
				p[i+1]=pi
				cnt+=1
print(min(cnt,n-1))