import math

n = int(input())
p = [x-1 for x in list(map(int, input().split()))]

c = 0
flag = 0
ans = 0

for i in range(n):
    if p[i] == i and flag:
        c += 1
    elif p[i] == i:
        c += 1
        flag = 1
    elif p[i] != i and c > 0:
        if c == 1:
            ans += 1
        else:
            ans += math.floor(c/2)
        
        c = 0
        flag = 0

if c == 1:
    ans += 1
else:
    ans += math.floor(c/2)

print(ans)