#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
const double EPS = 1e-9;
int mods(int a, int b) { return (b + (a % b)) % b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, b, a, d = 0, A[200005];
  cin >> n >> b >> a;
  int bat = b, acc = a;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) {
    if (A[i] == 1) {
      if (acc == a || (bat == 0 && acc > 0))
        acc--;
      else if (bat > 0 && acc < a) {
        bat--;
        acc++;
      } else
        break;
    } else {
      if (acc > 0)
        acc--;
      else if (bat > 0)
        bat--;
      else
        break;
    }
    d++;
    if (!bat && !acc) break;
  }
  cout << d << '\n';
  return 0;
}
