#include <bits/stdc++.h>
using namespace std;
int s[200123];
int n, b, a, aux1, aux2, resp;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> b >> a;
  for (int i = 0; i < n; i++) cin >> s[i];
  aux1 = a;
  aux2 = b;
  for (int i = 0; i < n; i++) {
    if (s[i] == 0) {
      if (a == aux1) {
        resp++;
        aux1--;
      } else {
        if (aux1 > 0) {
          resp++;
          aux1--;
        } else {
          if (aux2 > 0) {
            resp++;
            aux2--;
          } else {
            break;
          }
        }
      }
    } else {
      if (a == aux1) {
        resp++;
        aux1--;
      } else {
        if (aux2 > 0) {
          aux2--;
          resp++;
          aux1++;
        } else {
          if (aux1 > 0) {
            resp++;
            aux1--;
          } else {
            break;
          }
        }
      }
    }
  }
  cout << resp << endl;
  return 0;
}
