#include #include using namespace std; using namespace atcoder; using ll = long long; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vs = vector; using vp = vector>; #define rep(i, s, n) for (int i = (s); i < (int)(n); ++i) #define repr(i, s, n) for (int i = (s); i >= (int)(n); --i) #define sz(x) ((int)(x).size()) constexpr int INFI = 1001001001; constexpr ll INFL = (1LL << 60); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int a, b; cin >> a >> b; vi p (n); rep(i, 0, n){ cin >> p[i]; if(p[i] == 1) a--; else if( p[i] == 2) b--; else a--, b--; if(a < 0 || b < 0) { cout << i +1 << endl; return 0; } } cout << -1 << endl; return 0; }