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)

count = 0
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)