#include <bits/stdc++.h>
using namespace std;
void FAST() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve() {}
int main() {
  FAST();
  long long n, b, a, B, A;
  cin >> n >> B >> A;
  b = B;
  a = A;
  int s[n + 7];
  for (int first = 0; first < n; ++first) cin >> s[first];
  long long ans = 0;
  for (int first = 0; first < n; ++first) {
    if (s[first] == 0 && a > 0)
      a--;
    else if (s[first] == 0 && b > 0)
      b--;
    else if (s[first] == 1 && (a == A || (b == 0 && a > 0)))
      a--;
    else if (s[first] == 1 && b > 0)
      b--, a++;
    else
      break;
    ans++;
  }
  cout << ans;
  return 0;
}
