N = int(input()) A, B = list(map(int,input().split())) p = list(map(int,input().split())) ans = -1 for i in range(N): if p[i] & 1: A -= 1 if p[i] & 2: B -= 1 if A < 0 or B < 0: ans = i+1 break print(ans)