#jenga N=int(input()) a=[int(i) for i in input().split()] t=N i=N-1 c=0 #rint (a) while i>=0 and t>0: while i>=0 and a[i]!=t: # print (i) i-=1 if i>=0 and a[i]==t: c+=1 # print (i) # print (t) i-=1 t-=1 print (N-c)