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

    # if p[i] == i+1:
    #     if p[i-1] == i:
    #         del temp[-1]
    #         temp.append('x')
    #     else:
    #         temp.append('y')
    #     continue

    temp.append(p[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(temp)
ans = temp.count('x') + temp.count('y')
print(ans)