import sys

test =False
if test:
    N = 9
    items = [1,2,4,9,5,8,7,3,6]
else:
    N = int(raw_input())
    items = raw_input().split()
    items = [int(item) for item in items]
counter = 0
i = 0
if test:
    print items
while i < N:
    if i + 1 == items[i]:
        tmp = items[i+1]
        items[i+1] = items[i]
        items[i] = tmp
        counter += 1
        if test:
            print items
    i += 1
assert i == N
if items[N-1] == N:
    tmp = items[N]
    items[N] = items[N-1]
    items[N-1] = tmp
    counter += 1
    if test:
        print items
print counter
