n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
    if p[i] == i+1:
        ans += 1
        if i == 0:
            tmp = p[0]
            p[0] = p[1]
            p[1] = tmp
        elif i == n-1:
            tmp = p[-1]
            p[-1] = p[-2]
            p[-2] = tmp
        else:
            if p[i-1] != i + 1:
                tmp = p[i-1]
                p[i-1] = p[i]
                p[i] = tmp
            else:
                tmp = p[i+1]
                p[i+1] = p[i]
                p[i] = tmp

print(ans)
