N = int(input())

ans = 0
tmp_cnt = 0
for idx, p in enumerate(map(int, input().split())):
    idx += 1

    if idx == p:
        tmp_cnt += 1
    else:
        if tmp_cnt == 1:
            ans += tmp_cnt
        elif tmp_cnt >= 2:
            ans += tmp_cnt - 1
        tmp_cnt = 0

if tmp_cnt == 1:
    ans += tmp_cnt
elif tmp_cnt >= 2:
    ans += tmp_cnt - 1

print(ans)