n = int(input())
p = list(map(int, input().split()))
info = []
cnt = 0

for i in range(n):
    info.append(p[i] - i - 1)
print(info)


if n == 2:
    if p == [1, 2]:
        print(1)
        quit()
    else:
        print(0)
        quit()

for j in range(n - 2):
    if info[j] == 0:
        cnt += 1
        if info[j+1] == 0:
            cnt -= 1
        else:
            continue

if info[-2] == 0:
    cnt += 1
    if info[-1] == 0:
        cnt -= 1

if info[-1] == 0:
    cnt += 1

print(cnt)