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

x = []

for i in range(n):
    if p[i] == i+1:
        x.append(i)

x += [10**6]

s = e = 0
cnt = 1
ans = 0

for i in range(1, len(x)):
    if x[e] + 1 == x[i]:
        e += 1
        cnt += 1
    else:
        e += 1
        s = e
        if cnt > 1:
            ans += cnt-1
        else:
            ans += cnt
        cnt = 1

print(ans)