n = int(input())
P = list(map(int, input().split()))
ans0 = 0
ans = 0
co = 0
for i in range(n):
    if P[i] == i+1:
        co = 1
        ans0 += 1
    else:
        if co == 1:
            co = 0
            #print("seisan")
            ans += -((-ans0) // 2)
            ans0 = 0
print(ans)
