import sys input = sys.stdin.readline N=int(input()) A,B=list(map(int,input().split())) P=list(map(int,input().split())) ANS=-1 for i in range(N): p=P[i] if p==1: if A>=1: A-=1 else: ANS=i+1 break elif p==2: if B>=1: B-=1 else: ANS=i+1 break else: if A>=1 and B>=1: B-=1 A-=1 else: ANS=i+1 break print(ANS)