n = int(input())
p_array = [int(x) for x in input().split()]
p_dict = {}
for i, j in enumerate(p_array):
    p_dict[i + 1] = j
flags = [False for x in range(n)]
for i, j in p_dict.items():
    flags[i - 1] = i == j

cnt = sum([1 & x for x in flags])
now = False
duplicate = 0
for flag in flags:
    if flag:
        duplicate += 1
        now = True
    else:
        cnt -= 1 if duplicate >= 2 else 0
        duplicate = 0
        now = False
else:
    cnt -= 1 if duplicate >= 2 else 0

print(cnt)
