N = 9
PRR = [1, 2, 4, 9, 5, 8, 7, 3, 6]

N = 2
PRR = [2, 1]

N = 2
PRR = [1, 2]


N = 5
PRR = [1, 4, 3, 5, 2]

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

def calculate(n, prr):
    srr = []
    for i in range(n):
        if prr[i] == (i+1):
            srr.append(i)

    if len(srr) == 1:
        return 2

    result = 0

    for i in range(len(srr) //2):
        result += (srr[2*i+1] - srr[2*i])

    if len(srr) % 2 == 1:
        result += 1

    print(result)


calculate(N, PRR)
