#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = (int)1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ksm(long long a, long long b, long long mod) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }
void exgcd(long long a, long long b, long long &x, long long &y, long long &d) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    exgcd(b, a % b, y, x, d);
    y -= x * (a / b);
  }
}
const int MAX_N = 200025;
int arr[MAX_N];
pair<int, int> dp[MAX_N][2];
int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  memset(dp, -1, sizeof(dp));
  int ans = 0;
  dp[0][0] = dp[0][1] = make_pair(a, b);
  for (int i = 1; i <= n; ++i) {
    if (arr[i] == 1) {
      int tmp;
      if (dp[i - 1][0].first + dp[i - 1][0].second >
          dp[i - 1][1].first + dp[i - 1][1].second)
        tmp = 0;
      else
        tmp = 1;
      if (dp[i - 1][tmp].first <= 0 && dp[i - 1][tmp].second <= 0) {
        ans = max(ans, i - 1);
        break;
      }
      if (dp[i - 1][tmp].second <= 0)
        dp[i][1] = make_pair(dp[i - 1][tmp].first - 1, 0);
      else
        dp[i][1] = make_pair(dp[i - 1][tmp].first, dp[i - 1][tmp].second - 1);
      if (dp[i - 1][tmp].first <= 0)
        dp[i][0] = make_pair(0, dp[i - 1][tmp].second - 1);
      else
        dp[i][0] = make_pair(dp[i - 1][tmp].first - 1,
                             min(dp[i - 1][tmp].second + 1, b));
      ans = max(ans, i);
    } else {
      int tmp;
      if (dp[i - 1][0].first + dp[i - 1][0].second >
          dp[i - 1][1].first + dp[i - 1][1].second)
        tmp = 0;
      else
        tmp = 1;
      if (dp[i - 1][tmp].first <= 0 && dp[i - 1][tmp].second <= 0) {
        ans = max(ans, i - 1);
        break;
      }
      if (dp[i - 1][tmp].second <= 0)
        dp[i][1] = make_pair(dp[i - 1][tmp].first - 1, 0);
      else
        dp[i][1] = make_pair(dp[i - 1][tmp].first, dp[i - 1][tmp].second - 1);
      if (dp[i - 1][tmp].first <= 0)
        dp[i][0] = make_pair(0, dp[i - 1][tmp].second - 1);
      else
        dp[i][0] = make_pair(dp[i - 1][tmp].first - 1, dp[i - 1][tmp].second);
      ans = max(ans, i);
    }
  }
  printf("%d\n", ans);
  return 0;
}
