#include <bits/stdc++.h>
double const EPS = 3e-8;
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << "\t";
    return *this;
  }
} dbg;
template <class A, class B>
ostream& operator<<(ostream& o, const pair<A, B>& p) {
  return o << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)
    o << *it << ", ";
  return o << "]";
}
template <class T>
ostream& operator<<(ostream& o, const set<T>& v) {
  o << "[";
  for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)
    o << *it << ", ";
  return o << "]";
}
template <class T>
inline bool read(T& x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int NX = 1e6 + 10;
int inp[NX], n, lim_b, lim_a;
void solve() {
  n = ({
    int a;
    read(a);
    a;
  }),
  lim_b = ({
    int a;
    read(a);
    a;
  }),
  lim_a = ({
    int a;
    read(a);
    a;
  });
  int b = lim_b;
  int a = lim_a;
  for (int i = 1; i <= n; i++)
    inp[i] = ({
      int a;
      read(a);
      a;
    });
  int ans = 0;
  for (int i = 1; i <= n && (b > 0 || a > 0); i++) {
    if (inp[i] == 0) {
      if (a > 0) {
        a--;
      } else if (b > 0) {
        b--;
      }
    } else {
      if (b > 0 && a < lim_a) {
        b--;
        a++;
      } else if (a > 0) {
        a--;
      }
    }
    ans++;
  }
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
