#include <bits/stdc++.h>
using namespace std;
long long mark[5010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(), cout.tie();
  long long n, b, a, c, d, e, cnt = 0;
  cin >> n >> b >> a;
  long long s[n];
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
  }
  c = b;
  d = a;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 1) {
      if (d == a) {
        d = max((long long)0, min(a, d - 1));
        cnt++;
      } else if (c >= 1) {
        c = max((long long)0, min(b, c - 1));
        d = max((long long)0, min(a, d + 1));
        cnt++;
      } else if (d >= 1) {
        d = max((long long)0, min(a, d - 1));
        cnt++;
      }
    } else {
      if (d >= 1) {
        d = max((long long)0, min(a, d - 1));
        cnt++;
      } else if (c >= 1) {
        c = max((long long)0, min(b, c - 1));
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
