n = int(input())
p = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(1, n + 1):
    if p[i - 1] == i:
        cnt += 1
    if p[i - 1] != i or i == n:
        ans += cnt
        if cnt > 1:
            ans -= 1
        cnt = 0
print(ans)
