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

s=0
t=0

for i in range(N):
    if p[i]==i+1:
      s +=1
for i in range(N-1):
    if p[i]==i+1 and p[i+1]==i+2:
      t +=1

#print(s,t)    
print(t + (s-2*t))