#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 9;
int Case = 1;
int n, m, a, b, cc[maxn];
void solve() {
  cin >> n >> a >> b;
  int pa = a, pb = b, res = 0;
  for (int i = 1; i <= n; i++) {
    cin >> cc[i];
    if (cc[i]) {
      if (pb == b) {
        pb--;
        res++;
      } else {
        if (!pa && !pb) {
          cout << res << endl;
          return;
        }
        if (pa) {
          pa--;
          pb = min(pb + 1, b);
          res++;
        } else {
          pb--;
          res++;
        }
      }
    } else {
      if (!pa && !pb) {
        cout << res << endl;
        return;
      }
      if (pb) {
        pb--;
        res++;
      } else {
        pa--;
        res++;
      }
    }
  }
  cout << res << endl;
  return;
}
int main() {
  while (Case--) {
    solve();
  }
  return 0;
}
