#include <bits/stdc++.h>
int main() {
  int a, b, t, n, B;
  scanf("%d%d%d", &n, &a, &B);
  int cnt = 0, num = 0, flag = 1, temp = 0, cnt1 = 0;
  while (n--) {
    scanf("%d", &t);
    if (t == 1) {
      if (b <= 0 && flag) {
        temp = cnt;
        flag = 0;
      }
      if (a > 0)
        a--;
      else {
        if (b > 0)
          cnt++;
        else
          temp--;
      }
      if (temp < 0) num++;
    }
    b = B - cnt - cnt1;
    if (t == 2) {
      b--;
      cnt1++;
      if (b < 0) num = num + 2;
    }
  }
  printf("%d\n", num);
  return 0;
}
