import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    p = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    ls = []
    for i in range(n):
        if i + 1 != p[i]:
            if cnt != 0:
                ls.append(cnt)
                cnt = 0
        else:
            cnt += 1
    if cnt != 0:
        ls.append(cnt)
        cnt = 0
    cnt = 0
    for v in ls:
        cnt += v // 2 if v % 2 == 0 else v + 1 // 2
    print(cnt)


if __name__ == '__main__':
    solve()
