
N = int(input())
P = list(map(int,input().split()))
#PS = [i for i in range(1,N+1)]

cnt = 0
i = 0
idx = []
while i < N:
    if P[i] == i+1:
        if idx:
            if i == idx[0] + 1 :
                idx = []
            else:
                cnt += 1
                idx = []
        else:
            idx.append(i)
            cnt += 1
    i += 1   
print(cnt)
    
    