n = int(input())
ls = list(map(int,input().split()))
di = [0]*n
new = []
k = 0
for i in range(n):
    if ls[i] == i+1:
        di[i] = 1
        k += 1
    else:
        if k > 1:
            new.append(k)
        k = 0
if k > 1:
    new.append(k)
print(sum(di)-len(new))