
n=int(input())
p=list(map(int,input().split()))
m=[]
l=[0]*n
for i in range(n):
    if p[i]==i+1:
        l[i]=1
t=0

for i in range(n):
    if i==n-1:
        if l[i]==1:
            t+=1
        m.append(t)
        break
    if l[i]==1:
        t+=1
    else:
        m.append(t)
        t=0

ans=0
for mm in m:
    if mm>1:
        ans+=mm-1
    elif mm==1:
        ans+=1
print(ans)
