#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
const int LOGN = 20;
int s[maxn], n, a, b, ia, ib;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> b >> a;
  for (int i = 1; i <= (n); i++) cin >> s[i];
  ia = a, ib = b;
  for (int i = 1; i <= (n); i++) {
    if (s[i] == 0) {
      if (a > 0)
        a--;
      else if (b > 0)
        b--;
      else {
        cout << i - 1;
        return 0;
      }
    } else {
      if (b > 0 && a < ia)
        b--, a++;
      else if (a > 0)
        a--;
      else {
        cout << i - 1;
        return 0;
      }
    }
  }
  cout << n;
  return 0;
}
