import math

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

res = []
for i in range(n):
    if i + 1 == P[i]:
        res.append(P[i])

cnt = 0
for i in range(len(res) - 1):
    if res[i] + 1 == res[i + 1]:
        cnt += 1

print(len(res) - math.ceil(cnt / 2))
