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

import math
buf = []
prev = -1
for i, p in enumerate(P):
    if i+1 == p:
        buf.append(i+1)

if not buf:
    print(0)
    exit()


ret = 0
i = 0
while i < len(buf):
    j = i
    while j+1 < len(buf) and buf[j] + 1 == buf[j+1]:
        j += 1

    ret += max(1, j - i)
    i = j + 1


print(ret)