#include <bits/stdc++.h>
using namespace std;
int n, a, b, ans, nowa, nowb, f[200010];
int main() {
  scanf("%d%d%d", &n, &a, &b);
  nowa = a;
  nowb = b;
  for (int i = 1; i <= n; i++) scanf("%d", &f[i]);
  for (int i = 1; i <= n; i++) {
    if (!nowa && !nowb) break;
    if (f[i] && nowa && nowb < b)
      nowa--, nowb++;
    else {
      if (nowb)
        nowb--;
      else
        nowa--;
    }
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
