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 if P[i] == 2: B -= 1 if P[i] == 3: A -= 1 B -= 1 if A == -1 or B == -1: print(i+1) exit(0) print(-1)