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

res1 = 0
for i in range(1, len(P) - 1):
    if i == P[i]:
        P[i], P[i + 1] = P[i + 1], P[i]
        res1 += 1

res2 = 0
for i in range(len(P)-1, 1, -1):
    if i == P[i]:
        P[i], P[i - 1] = P[i - 1], P[i]
        res2 += 1

print(min(res1, res2))

