n=int(input())
P=list(map(int,input().split()))
Q=["*"]*n

for i in range(n):
    if P[i]==i+1:Q[i]="#"

ans,cnt,point=0,0,0
while cnt!=n:
    if Q[cnt]=="#":point +=1
    elif Q[cnt]=="*" and point>=1:
        if point==1:ans +=1
        else:ans +=point-1
        point=0
    cnt +=1

print(ans)