N = int(input())
p = list(map(int, input().split()))
count = 0
n = 0
for i in range(N-1):
    if p[i] == i+1:
        count += 1
        if p[i + 1] == i + 2:
            n += 1
if p[N-1] == N:
    count+=1
print(count-n)
