import itertools
def solve():
    N = int(input())
    p = list(map(int, input().split()))
    chk = ""

    for i in range(N):
        if p[i] == i + 1:
            chk += "1"
        else:
            chk += "0"
    
    chk_splited = chk.split('0')

    cnt = 0
    for c in chk_splited:
        if len(c) % 2 == 0:
            cnt += len(c) / 2
        else:
            cnt += len(c) //2 + 1
    print(int(cnt))

if __name__ == '__main__':
    solve()
