#coding:utf-8

def add_count(zero_count):
    if zero_count >= 2:
        return zero_count - 1
    else:
        return zero_count

N = int(input())
p_list = list(map(int, input().split(" ")))

diff = map(lambda x, y: x - y, p_list, list(range(1, N + 1)))

count = 0
zero_count = 0
for i, val in enumerate(diff):
    if val == 0:
        zero_count += 1
        if i == N - 1:
            count += add_count(zero_count)
    else:
        count += add_count(zero_count)
        zero_count = 0
print (count)

