import numpy as np
N = int(input())
p = list(input().split())
p = [int(i) for i in p]
same_i = []
for i in range(len(p)):
    if p[i] == int(i+1):
        same_i.append(int(i+1))

renzoku = []
renzoku_flag = False
for i in range(len(same_i)-1):
    if same_i[i]+1 == same_i[i+1]:
        if renzoku_flag == False:
            start = same_i[i]
        renzoku_flag = True
    else:
        if renzoku_flag == True:
            end = same_i[i]
            renzoku.append(end-start+2)
            renzoku_flag = False
if renzoku_flag == True:
    end = same_i[i]
    renzoku.append(end-start+2)
    renzoku_flag = False

a = [renzoku[i]-1 for i in range(len(renzoku))]
print(len(same_i)-sum(renzoku)+sum(a))
