n=int(input())
p=list(map(int,input().split()))
cnt=0
li=[]
nu=[]
for i in range(n):
    if i+1==p[i]:
        cnt+=1
        li.append(p[i])
        nu.append(i+1)
ans=0
streak=0
for i in range(cnt):
    if nu[i-1]+1==nu[i]:
        streak+=1
    else:
        ans+=1+streak//2        
        streak=0
print(ans)
