#include <bits/stdc++.h>
using namespace std;
void PrintVector(vector<int> v2, string s = "") {
  cout << s;
  for (int i = 0; i < v2.size(); i++) cout << v2[i] << " ";
  cout << endl;
}
int isOdd(int x) { return (x % 2); }
int toInt(string str) {
  int num;
  istringstream iss(str);
  iss >> num;
  return num;
}
template <class T>
string toStr(T par) {
  ostringstream oss;
  oss << par;
  return oss.str();
}
void readVector(vector<int>& vec, int len) {
  for (int i = 0; i < len; i++) {
    cin >> vec[i];
  }
}
int main() {
  int N, a, b, aMax, bMax, distance = 0;
  cin >> N >> b >> a;
  bMax = b;
  aMax = a;
  vector<int> track(N);
  readVector(track, N);
  for (int i = 0; i < N; i++) {
    if (track[i]) {
      if (a == aMax) {
        distance++;
        a--;
      } else if (b > 0) {
        b--;
        distance++;
        if (a < aMax) a++;
      } else if (a > 0) {
        a--;
        distance++;
      }
    } else {
      if (a > 0) {
        a--;
        distance++;
      } else if (b > 0) {
        b--;
        distance++;
      }
    }
  }
  cout << distance << endl;
  return 0;
}
