def runLength(string):
    """文字列strをランレングス圧縮して返す関数
    ex: "0000111101" => [(0,4), (1,4), (0,1), (1,1)]
    """
    res = []
    data, count = string[0], 1
    for i in range(1, len(string)):
        if string[i] == data:
            count += 1
        else:
            res.append((data, count))
            data, count = string[i], 1
    res.append((data, count))
    return res


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

check = "".join(["1" if p[i] == i+1 else "0" for i in range(N)])
rl =runLength(check)

ans = 0
for rli in rl:
    if rli[0] == "1":
        if rli[1] == 1:
            ans += 1
        else:
            ans += rli[1] - 1

print(ans)
