def D_Derangement():
    try:
        LOCAL_FLAG
        N = 5
        raw_p = "1 4 3 5 2"
        p = list(map(int, raw_p.split()))

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

    bad = []
    for i in range(N):
        if(p[i] == i+1):
            bad.append(i+1)

    n_bad = len(bad)
    n_ope = n_bad
    
    for i in range(n_bad-1):
        if(bad[i] == (bad[i+1]-1)):
            n_ope -= 1

    print(n_ope)
    pass

D_Derangement()