import copy

n=int(input())
f1=list(map(int,input().split()))
f2=copy.deepcopy(f1)
c=0
for i in range(n-1):
    if f1[i]==i+1:
        c+=1
        f1[i],f1[i+1]=f1[i+1],f1[i]
d=0
for i in range(n-1,0,-1):
    #print(d)
    if f2[i-1]==i:
        d+=1
        f2[i],f2[i-1]=f2[i-1],f2[i]

print(min(c,d))
