n=int(input())
p=list(map(int,input().split()))
cnt=0
li=[]
nu=[]
for i in range(n):
    if i+1==p[i]:
        cnt+=1
        li.append(p[i])
        nu.append(i+1)
#print(cnt)
#print(li)
ans=0
streak=0
for i in range(cnt):
    if nu[i-1]+1==nu[i]:
        streak+=1
        if streak==2:
            ans+=1
            streak=0
    else:
        ans+=1
print(ans)
