N=int(input())
p=list(map(int, input().split()))
p = [0] + p
ids = []
ans = 0
for i in range(1, 1+N):
    if p[i] == i:
        if not ids:
            ids.append(i)
            ans += 1
        else:
            if ids[-1] + 1 == i:
                continue
            ans += 1
print(ans) 