N = int(input())
p = [int(i) for i in input().split(" ")]
ans = 0

for i in range(0,N):
    if p[i] == (i+1):
        if p[i+1] == (i+1):
            t = p[i]
            p[i] = p[i+1]
            p[i+1] = t
            ans += 1
        else:
            ans += 1
            d = -1 if i == N-1 else 1
            t = p[i]
            p[i] = p[i+d]
            p[i+d] = t
            
print(ans)
