#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int v[201000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, b, a;
  cin >> n >> b >> a;
  int B = b, A = a;
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 1; i <= n; i++) {
    if (a == A)
      a--;
    else if (v[i - 1] && b) {
      b--;
      a++;
    } else if (a)
      a--;
    else if (b)
      b--;
    else {
      cout << i - 1 << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}
