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
    a_cnt = 0
    for i in range(n):
        if p[i] == i + 1:
            cnt += 1
        else:
            if cnt != 0:
                if cnt == 1:
                    a_cnt += 1
                else:
                    a_cnt += cnt - 1
                cnt = 0
    if cnt != 0:
        if cnt == 1:
            a_cnt += 1
        else:
            a_cnt += cnt - 1
    print(a_cnt)


if __name__ == '__main__':
    solve()
