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

now = False
cnt = 0
for flag in flags:
    if flag:
        if now:
            pass
        else:
            cnt += 1
    now = flag
print(cnt)
