#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, bc, ac, a[200005], ans = 0, mc;
  cin >> n >> bc >> ac;
  mc = ac;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      if (ac > 0) {
        ans++;
        ac--;
      } else if (bc > 0) {
        ans++;
        bc--;
      }
    } else {
      if (ac == mc) {
        ans++;
        ac--;
      } else if (bc > 0) {
        ans++;
        bc--;
        ac++;
        if (ac > mc) ac--;
      } else if (ac > 0) {
        ans++;
        ac--;
      }
    }
    if (bc == 0 and ac == 0) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
