n = int(raw_input()) l = map(int, raw_input().split()) m = n p = n-1 c = 0 while p >= 0: if m != l[p]: c += 1 else: m -= 1 p -= 1 print c