N=int(input())

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

count=0
b=[0]*N

for i in range(N):
    if a[i]==i+1:
        b[i]=1
    
count = 0
ans = 0
    
for i in range(N):
    if b[i]==1:
        count+=1
    else:
        if count==1:
            count=2
        if count>0:
            ans+=count-1
            count=0

if count>0:
    if count==1:
        count=2
    ans+=count-1   

print(ans)