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