def solve(a): tomove = [] n = len(a) for i in range(n-1, -1, -1): if n != a[i]: tomove.append(a[i]) else: n -= 1 return len(tomove) n = int(input()) a = list(map(int, input().split())) print(solve(a))