#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void read(vector<int> &a) {
  for (auto &it : a) cin >> it;
}
void Solve() {
  int n, b, a;
  cin >> n >> b >> a;
  vector<int> x(n);
  read(x);
  vector<int> dp[2];
  int ma = a, mb = b;
  if ((a + b) >= n) {
    cout << n << "\n";
    return;
  }
  for (int i = 0; i < n; i++) {
    if (x[i] == 1 && a == ma) {
      a--;
    } else if (x[i] == 1 && b > 0) {
      b--;
      a++;
    } else if (x[i] == 1 && a > 0) {
      a--;
    } else if (x[i] == 0 && a > 0) {
      a--;
    } else if (x[i] == 0 && b > 0) {
      b--;
    } else {
      cout << i << "\n";
      return;
    }
  }
  cout << n << "\n";
}
int32_t main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  Solve();
  return 0;
}
