n=int(input()) a,b=map(int,input().split()) p=list(map(int,input().split())) for i in range(n): if p[i]==1: a-=1 elif p[i]==2: b-=1 elif p[i]==3: a-=1 b-=1 if a==-1 or b==-1: print(i+1) exit() print(-1)