n=int(input())
p=list(map(int,input().split()))
m=0
d=[]
t=[]
for i in range(n):
    if p[i]==i+1:
        d.append(i)
for i in range(1,len(d)):
    if d[i]==1+d[i-1] and i-1 not in t:
        t.append(i)
        t.append(i-1)
print(len(d)-len(t)//2)