import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A = map(int, read().split()) pos = [0] * (N + 1) for i, x in enumerate(A): pos[x] = i use = [0] * (N + 1) for x in range(1, N + 1): p = pos[x] if p == N - 1 or not use[A[p + 1]]: use[x] = 1 print(sum(use))