n = int(input())
a = list(map(int, input().split()))

b=[]

for i in range(n):
    if(a[i]==i+1):
        b.append(1)
    else:
        b.append(0)
        
#print(b)
count = 0
if(n>=3):
    for i in range(n-2):
        prev = b[i]
        now = b[i+1]
        if(prev+now == 2):
            count+=1
            b[i+1]=0
        elif(prev==1 and now ==0):
            count+=1
            
    if(b[n-1]==1):
        count+=1
    print(count)
else:
    if(sum(b)>=1):
        print(1)
    else:
        print(0)
