N = int(input())
P = list(map(int, input().split()))

ans = 0
cnt = 0

f = 0
for i, v in enumerate(P):
    if not f:
        if i+1 == v:
            f = 1
    else:
        cnt += 1
        if i+1 == v:
            ans += cnt
            f = 0
            cnt = 0
    # print(f"i{i} v{v} ans{ans} cnt{cnt} f{f}")
print(ans + f)