N = int(input()) A,B = map(int,input().split()) P = list(map(int,input().split())) for i,p in enumerate(P): if p==1: A -= 1 elif p==2: B -= 1 else: A -= 1 B -= 1 if A < 0 or B < 0: print(i+1) exit() print(-1)