#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, bat, acu, ans = 0;
  cin >> n >> bat >> acu;
  int b = bat, ac = acu;
  bool sun;
  for (int i = 0; i < n; i++) {
    cin >> sun;
    if (bat == 0 && acu == 0) return cout << ans << endl, 0;
    if (bat > 0 && acu < ac && sun == 1) {
      ans++;
      bat--;
      acu++;
    } else if (acu > 0) {
      ans++;
      acu--;
    } else if (bat > 0) {
      ans++;
      bat--;
      if (acu < ac && sun == 1) acu++;
    }
  }
  return cout << ans << endl, 0;
}
