from sys import stdin N, *R = map(int, stdin.read().split()) i = R[0] ztm = [] ztm.append(i) res = 0 while i != N: i = max(R[:i]) if i in ztm: maxindex = rindex(R[:i]) R[maxindex] = 0 else: res += 1 print(res+1)