#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, a, en, i, temp, d = 0;
  cin >> n >> b >> a;
  int ca = a, cb = b;
  for (i = 0; i < n; i++) {
    cin >> temp;
    if (temp) {
      if (cb == 0 || ca == a)
        ca--;
      else {
        ca++;
        cb--;
      }
    } else {
      if (ca == 0)
        cb--;
      else
        ca--;
    }
    d++;
    if (ca == 0 && cb == 0) break;
  }
  cout << d << endl;
}
