#include <bits/stdc++.h>
using namespace std;
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
T min(T a, T b, T c, T d) {
  return min(a, min(b, min(c, d)));
}
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
T max(T a, T b, T c, T d) {
  return max(a, max(b, max(c, d)));
}
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.first > b.first || (a.first == b.first && a.second >= b.second));
}
long long GCD(long long a, long long b) { return (a % b) ? GCD(b, a % b) : b; }
const string namePro = "tmp";
int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  int ans = 0;
  int cnt1 = a;
  int cnt2 = b;
  int cnt3 = 0;
  for (int i = (1); i <= (n); ++i) {
    int x;
    scanf("%d", &x);
    if (x == 1) {
      if (cnt1)
        --cnt1;
      else if (cnt2) {
        --cnt2;
        ++cnt3;
      } else if (cnt3)
        --cnt3;
      else
        ++ans;
    } else {
      if (cnt2)
        --cnt2;
      else
        ++ ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
