#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, b, ac;
  cin >> n >> b >> ac;
  long long mb = b, mc = ac;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long dun = n;
  for (long long i = 0; i < n; i++) {
    if (ac == mc) {
      ac--;
      if (ac == 0 and b == 0) {
        dun = i + 1;
        break;
      }
    } else {
      if (a[i] == 0) {
        if (ac != 0)
          ac--;
        else if (b != 0)
          b--;
        if (ac == 0 and b == 0) {
          dun = i + 1;
          break;
        }
      } else if (a[i] == 1) {
        if (b != 0) {
          ac++;
          b--;
        } else if (ac != 0)
          ac--;
        if (ac == 0 and b == 0) {
          dun = i + 1;
          break;
        }
      }
    }
  }
  cout << dun << "\n";
  return 0;
}
