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

P = [p-1 for p in P]
ans = 0
id = []
for i in range(n):
    if i == P[i]:
        id.append(i)
if len(id) == 0:
    print(0)
    exit()
id.sort()
ans = len(id)
for i in range(len(id)-1):
    if id[i+1]== id[i]+1:
        ans -= 1
print(ans)
