n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
ans=0
flg=True
for i in range(1,n):
    if a[i]==i and a[i-1]==i-1 and flg:
        if flg:
            ans-=1
            flg=False
        else:
            flg=True
for i in range(n):
    if a[i]==i:
        ans+=1
print(ans)
