from sys import stdin import threading threading.stack_size(10 ** 8) def main(): 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 ztm.append(i) print(res+1) if __name__ == "__main__": t = threading.Thread(target=main) t.start() t.join()