#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
void open() {
  ((void)0);
  ((void)0);
  ((void)0);
}
const int MAX = 1e5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1);
const long double ERR = 1e-10;
const int move_r[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int move_c[] = {0, -1, 0, 1, -1, 1, -1, 1};
int N, B, C, A, ans;
int MAP[2 * MAX];
int main(int argc, char *argv[]) {
  open();
  scanf("%d %d %d", &N, &B, &A);
  C = A;
  for (int i = 0; i < N; ++i) scanf("%d", MAP + i);
  for (int i = 0; i < N; ++i) {
    if (MAP[i]) {
      if (A == C) {
        ans++;
        A--;
      } else if (B > 0) {
        ans++;
        B--;
        A++;
      } else if (A > 0) {
        ans++;
        A--;
      }
    } else {
      if (A > 0) {
        A--;
        ans++;
      } else if (B > 0) {
        B--;
        ans++;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
