#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b_max, accu_max;
  cin >> n >> b_max >> accu_max;
  int i = 0;
  int b = b_max;
  int a = accu_max;
  vector<int> v;
  int c;
  for (i = 0; i < n; i++) {
    cin >> c;
    v.push_back(c);
  }
  i = 0;
  while (i < n && (b > 0 || a > 0)) {
    if (b == 0) {
      a--;
    } else if (a == 0) {
      b--;
      if (v[i] == 1) a++;
    } else {
      if (a == accu_max || v[i] == 0) {
        a--;
      } else {
        b--;
        a++;
      }
    }
    i++;
  }
  cout << i << endl;
  return 0;
}
