#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, b, a, s[200001], k;
  cin >> n >> b >> a;
  k = a;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    if (s[i] == 0 && a > 0)
      a--;
    else if (s[i] == 0 && a == 0)
      b--;
    else if (s[i] == 1 && (a == k || b == 0)) {
      a--;
    } else if (s[i] == 1 && b > 0 && a < k)
      b--, a++;
    if (a == 0 && b == 0) {
      cout << i + 1;
      return 0;
    }
  }
  cout << n;
}
