#include <bits/stdc++.h>
using namespace std;
string mirror = "AHIMOTUVWXY";
long long mx_a, a, b;
void battery(long long x) {
  if (x) a = min(a + 1, mx_a);
  b--;
}
void accumulator(long long x) { a--; }
void tazim() {
  long long n, m, i, j, k, x, y, q;
  cin >> n >> b >> a;
  mx_a = a;
  vector<long long> v(n);
  for (i = 0; i < n; i++) cin >> v[i];
  long long ans = 0;
  for (i = 0; i < n; i++) {
    if (!a && !b)
      break;
    else if (!a) {
      battery(v[i]);
    } else if (!b) {
      accumulator(v[i]);
    } else if (v[i] && a < mx_a) {
      battery(v[i]);
    } else {
      accumulator(v[i]);
    }
  }
  cout << i << endl;
}
int main() {
  long long t;
  tazim();
}
