#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, b, a, i, travelled, accum_max;
  cin >> n >> b >> a;
  accum_max = a;
  long long int vec[n];
  for (i = 0; i < n; i++) cin >> vec[i];
  travelled = 0;
  for (i = 0; i < n; i++) {
    if (vec[i] == 0) {
      if (a > 0) {
        a--;
        travelled++;
      } else if (b > 0) {
        b--;
        travelled++;
      } else {
        cout << travelled << endl;
        return 0;
      }
    } else {
      if (b > 0) {
        b--;
        if (a == accum_max) {
          a--;
          b++;
        } else {
          a++;
        }
        travelled++;
      } else if (a > 0) {
        a--;
        travelled++;
      } else {
        cout << travelled << endl;
        return 0;
      }
    }
  }
  cout << travelled << endl;
  return 0;
}
