n = int(input())
p = list(map(int,input().split()))
ans = 0

for i in range(n-1):
    if (i != 0) and (i != n-1):
        if i == p[i]-1:
            if i-1 == p[i-1]-1 and i+1 == p[i+1]-1:
                ans += 1
    if i == p[i]-1:
        ans += 1
        p[i],p[i+1] = p[i+1],p[i]

print(ans)