#include <bits/stdc++.h>
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
using namespace std;
void file() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  file();
  int n, a, b, aa, ans = 0;
  cin >> n >> b >> a;
  aa = a;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    if (v[i] == 1 && b && a != aa) {
      b--;
      a = min(a + 1, aa);
    } else if (v[i] == 1 && a)
      a--;
    else if (v[i] == 1 && b)
      b--;
    else if (v[i] == 0 && a)
      a--;
    else if (v[i] == 0 && b)
      b--;
    else
      break;
    ans++;
  }
  cout << ans << '\n';
}
