N=int(input())
p=list(map(int,input().split()))
swap=[0,0]
cnt=0
for i in range(N):
    if (p[i]==i+1):
        if swap[0]==0:
            swap[0]=i+1
        else:
            swap[1]=i+1
            #print(swap)
            cnt=cnt+min(2,swap[1]-swap[0])
            swap=[0,0]
print(cnt)

