n = int(input())
p = list(map(int, input().split()))
temp = []

for i in range(n):
    # print(i, p[i])
    if p[i] == i+1:
        temp.append('y')
        continue

    temp.append(p[i])

a = []

for i in range(1, len(temp)):
    if temp[i] == 'y' and temp[i-1] == 'y':
        a.append('x')
    else:
        a.append(temp[i])

# idx = 1
# while True:
#     if idx > len(temp) - 1:
#         break
#
#     if temp[idx] == 'y' and temp[idx-1] == 'y':
#         temp[idx-1] = 'x'
#         del temp[idx]
#         # del temp[idx-1]
#         # temp.append('x')
#
#     idx += 1


#print(a)
ans = a.count('x') + a.count('y')
print(ans)


'''
9
1 2 4 9 5 8 7 3 6
'''
