#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, b, a;
  cin >> n >> a >> b;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  int acc = b, batt = a, ans = 0;
  for (int i = 0; i < n; i++) {
    if (!batt && !acc) break;
    if (vec[i] == 0) {
      if (acc)
        acc--;
      else
        batt--;
    } else {
      if (acc == b)
        acc--;
      else {
        if (batt) {
          if (acc < b) acc++;
          batt--;
        } else
          acc--;
      }
    }
    ans = i + 1;
  }
  cout << ans;
}
