N=int(input())
p=list(map(int,input().split()))
D=[]
for i in range(1,N+1):
    if i==p[i-1]:
        D.append(1)
    else:
        D.append(0)
D.append(0)
tmp=0
ans=0
for i in range(N+1):
    if D[i]==1:
        tmp+=1
    else:
        if tmp==1:
            ans+=tmp
        elif tmp>=2:
            ans+=tmp-1
        tmp=0
print(ans)
