n=int(input())
p=list(map(int,input().split()))
p0=p[0]
cnt=0
ans=0
if p0==1:
	cnt = 0
	ans = 1

for i in range(1,n):
	p1=p[i]
	if p1==i+1:
		if p0==i:
			cnt = 0
		else:
			cnt = 1
			ans += 1
	else:
		cnt = 0
print(ans)