N=input()
a=map(int, raw_input().split())
#print N
#print a

b=[]
for i in range(1,len(a)+1):
	#print i,a[i-1]
	if i==a[i-1]:
		b.append(a[i-1])

#print b
rinsetsu_cnt=0
for j in range(len(b)):

	if j<len(b)-1:
		if b[j+1]-b[j]==1 and b[1]-b[j-1]!=1:
			rinsetsu_cnt+=1


#print rinsetsu_cnt
print len(b)-rinsetsu_cnt
