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)

    result = 0

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

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


calculate(N, PRR)
