#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, b, a, cura, curb, step = 0;
  vector<long long int> v;
  cin >> n >> b >> a;
  cura = a;
  curb = b;
  for (int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    v.push_back(x);
  }
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == 0) {
      if (cura > 0) {
        cura--;
        step++;
      } else if (curb > 0) {
        curb--;
        step++;
      } else {
        break;
      }
    } else {
      if (cura == a) {
        cura--;
        step++;
      } else if (curb > 0) {
        curb--;
        step++;
        cura++;
      } else if (cura > 0) {
        cura--;
        step++;
      } else {
        break;
      }
    }
  }
  cout << step;
  return 0;
}
