N=int(input())
A=list(map(int, input().split()))

pre=(A[0]==1)
count=0
ans=0
if pre:
  count+=1
for i in range(1,N):
  if pre:
    if A[i]!=i+1:
      ans+=ceil(count/2)
      count=0
      pre=False
    else:
      count+=1
  else:
    if A[i]==i+1:
      count+=1
      pre=True
if pre:
  ans+=ceil(count/2)
print(ans)