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

for i in range(n):
    # print(i, p[i])
    if i == 0 and 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])
 
#print(temp)
ans = temp.count('x') + temp.count('y')
print(ans)


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