import copy
n = input()
swap = 0
swap2 = 0
flag = False
buff = -1
ai = list(int(i) for i in input().split())
bi = copy.deepcopy(ai)
for i in range(len(ai)-1):
    if i+1 == ai[i]:
        if not(flag):
            tmp = ai[i]
            ai[i] = ai[i+1]
            ai[i+1] = tmp
            swap = swap + 1
           # print(str(swap)+"回目"+str(ai))
for j in range(len(bi)-1):
    i = len(bi) - j - 1
   # print(i)
    tmp = bi[i]
    bi[i] = bi[i-1]
    bi[i-1] = tmp
    swap2 = swap2 + 1
   # print("逆順"+str(swap2)+"回目"+str(bi))
#print(ai)
#print(bi)
#print(swap)
#print(swap2)
print(min(swap, swap2))

