#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, b, a1;
  cin >> n >> b >> a1;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long p;
  p = a1;
  for (long long i = 0; i < n; i++) {
    if (p == a1) {
      p--;
      continue;
    }
    if (a[i] == 1) {
      if (b) {
        b--;
        p++;
      } else if (p) {
        p--;
      } else {
        cout << i;
        return;
      }
    } else {
      if (p)
        p--;
      else if (b)
        b--;
      else {
        cout << i;
        return;
      }
    }
  }
  cout << n << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
