#include <bits/stdc++.h>
using namespace std;
long n, k, i, j, x;
map<long, long> b;
priority_queue<pair<long, long> > c;
long long a[1000005];
int main() {
  long long n, x, y;
  cin >> n >> x >> y;
  long long z = y;
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long i, jj;
  for (i = 0; i < n; i++) {
    if (a[i] == 0) {
      if (y > 0) {
        y--;
      } else if (x > 0) {
        x--;
      } else {
        jj = i + 1;
        break;
      }
    } else {
      if (x > 0 && y != z) {
        x--;
        y++;
      } else if (y > 0) {
        y--;
      } else {
        jj = i + 1;
        break;
      }
    }
  }
  cout << i;
  return 0;
}
