#include <bits/stdc++.h>
using namespace std;
const int N = 210000;
int n;
int h[N];
int b, a;
int main() {
  cin >> n >> b >> a;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  int ta = a;
  int i;
  for (i = 1; i <= n; i++) {
    if (h[i] == 0) {
      if (a > 0) {
        a--;
        if (b == 0 && a == 0) {
          cout << i << endl;
          break;
        }
      } else {
        if (b > 0) {
          b--;
        }
        if (b == 0) {
          cout << i << endl;
          break;
        }
      }
    } else if (h[i] == 1) {
      if (b > 0 && a < ta) {
        b--;
        a++;
      } else if (b > 0 && a == ta) {
        a--;
      } else if (b == 0 && a > 0) {
        a--;
      }
      if (b == 0 && a == 0) {
        cout << i << endl;
        break;
      }
    }
  }
  if (a > 0 && b > 0 && i == n + 1) {
    cout << n << endl;
  } else if (a > 0 && b == 0 && i == n + 1) {
    cout << n << endl;
  } else if (a == 0 && b > 0 && i == n + 1) {
    cout << n << endl;
  }
  return 0;
}
