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