n = int(input())
a = list(map(int, input().split()))

l = [0] * (n + 2)
for i in range(n):
    if a[i] == i + 1:
        l[i + 1] = 1
count = sum(l)
for i in range(1, n + 1):
    if l[i] == 1:
        if l[i - 1] == 0 and l[i + 1] == 0:
            count += 1
if count % 2 == 1:
    print(count // 2 + 1)
else:
    print(count // 2)