n = int(input())
p = list(map(int, input().split()))

ans = 0
c = 0
for i in range(n):
    if p[i] == i+1:
        c += 1
    if p[i] != i+1:
        if c > 1:
            ans += c - 1
        elif c == 1:
            ans += c
        c = 0

if c == n:
    ans += c- 1 

print(ans)