N=int(input())
p=list(map(int,input().split()))
q=['x' for _ in range(N)]
ans=0
for i in range(N):
    if p[i]!=i+1:
        q[i]='o'
for i in range(N):
    if q[i]=='x':
        if i<N-1:
            p[i], p[i+1]=p[i+1], p[i]
        else:
            p[i], p[i-1]=p[i-1], p[i]
        q[i]='o'
        q[i+1]='o'
        ans+=1

print(ans)
