#include #ifdef LOCAL #include #else #define debug(...) #endif using namespace std; namespace rv = std::views; // NOLINT // clang-format off using lint = long long; using P = pair; #define ALL(a) (a).begin(), (a).end() template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } inline void Yes(bool b = true) { println("{}",(b ? "Yes" : "No")); } inline void No() { println("{}", "No");} // clang-format on int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, A, B; cin >> N >> A >> B; int ans = -1; for (int i = 0; i < N; i++) { int op; cin >> op; if (op == 1) { A--; } else if (op == 2) { B--; } else { A--; B--; } if (A < 0 || B < 0) { ans = i + 1; break; } } println("{}", ans); }