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