#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, a;
  cin >> n >> b >> a;
  int *arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int count = 0;
  int max = a;
  for (int i = 0; i < n; i++) {
    if (!arr[i] && a) {
      a--;
      count++;
    } else if (!arr[i] && !a) {
      b--;
      count++;
    } else if (arr[i] && (a < max)) {
      b--;
      a++;
      count++;
    } else if (arr[i] && (a == max)) {
      a--;
      count++;
    }
    if (!b) {
      count += a;
      break;
    }
  }
  if (count <= n)
    cout << count;
  else
    cout << n;
  delete[] arr;
  return 0;
}
