N = int(input()) A, B = map(int, input().split()) P = list(map(int, input().split())) i = 0 while i < N and A >= 0 and B >= 0: A -= 1 if P[i] != 2 else 0 B -= 1 if P[i] != 1 else 0 i += 1 print(i if i < N else -1)