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