n=int(input())
a=list(map(int,input().split()))
con=0
ans=0
for i in range(n):
  if a[i]==i+1:
    con+=1
  else:
    if con==1 or con==2:
      ans+=1
      con=0
    elif con!=0:
      ans+=con-1
      con=0
if con==1 or con==2:
      ans+=1
      con=0
elif con!=0:
      ans+=con-1
      con=0
print(ans)      