#include <bits/stdc++.h>
inline int read() {
  register int ans = 0;
  register char c = getchar();
  register bool neg = 0;
  while (c < 48 || c > 57) neg ^= !(c ^ '-'), c = getchar();
  while (c >= 48 && c <= 57)
    ans = (ans << 3) + (ans << 1) + (c ^ 48), c = getchar();
  return neg ? -ans : ans;
}
const int M = 2E5 + 11;
int n, a, al, b, ans = 0, t_b, P[M];
int main(void) {
  n = read(), a = read(), b = t_b = read();
  for (int i = 1; i <= n; ++i) P[i] = read();
  al = a;
  while ((al || t_b) && ans++ <= n) {
    if (!P[ans]) {
      if (t_b)
        --t_b;
      else
        --al;
    } else {
      if (t_b < b && al)
        ++t_b, --al;
      else
        --t_b;
    }
    if (ans == n) break;
  }
  printf("%d\n", ans);
  return 0;
  printf("%d\n", ans);
}
