n=int(input())
p=list(map(int,input().split()))
streak=0
a=0
for i in range(n-1):
    if i+1==p[i]:
        streak+=1
        if i+2!=p[i+1]:
            a+=-streak//2
            streak=0
a+=-streak//2
print(-a)