N = int(input())
P = [0] + list(map(int, input().split()))

L = [False for i in range(N + 1)]
for i, v in enumerate(P):
    L[i] = i == v

res = 0
tmp = True
for l in L:
    if not l:
        res += 1
    if not(tmp or l):
        res -= 1
    tmp = l

print(res)
