#include <bits/stdc++.h>
using namespace std;
vector<long long> a, b, ind;
bool mysort(int i, int j) {
  if (b[i]) {
    if (b[j]) {
      return a[i] > a[j];
    } else {
      return 0;
    }
  } else if (b[j]) {
    return 1;
  } else {
    return a[i] > a[j];
  }
}
vector<bool> _;
vector<vector<bool> > dp, dpu;
int main() {
  _.assign(10002, false);
  long long n, l, r, hi, lo, cnt = 0;
  cin >> n >> l >> r;
  a.assign(n, 0);
  b.assign(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    cnt += b[i];
  }
  for (int i = 0; i < n; i++) {
    ind.push_back(i);
  }
  lo = 0;
  hi = cnt + 1;
  sort(ind.begin(), ind.end(), mysort);
  dp.assign(n + 2, _);
  dpu.assign(n + 2, _);
  for (int i = 0; i < n + 1; i++) dp[i][0] = 1;
  for (int j = 0; j < 10001; j++) {
    for (int i = 0; i < n; i++) {
      if (dp[i][j]) {
        dp[i + 1][j + a[ind[i]]] = 1;
        dp[i + 1][j] = 1;
        if (i >= n - cnt) {
          if (dpu[i][j]) {
            dpu[i + 1][j + a[ind[i]]] = 1;
            dpu[i + 1][j] = 1;
          } else {
            dpu[i + 1][j] = 1;
          }
        }
      }
    }
  }
  while (lo + 1 < hi) {
    long long m = (hi + lo) / 2;
    long long s = 0, lim;
    for (int i = n - 1; i >= n - m + 1; i--) s += a[ind[i]];
    lim = r - s;
    if (lim < l) {
      hi = m;
    } else {
      bool check = 0;
      for (int j = l; j < lim + 1; j++) {
        if (dp[n - m + 1][j] && dpu[n - m + 1][j]) {
          check = 1;
          break;
        }
      }
      if (check) {
        lo = m;
      } else {
        hi = m;
      }
    }
  }
  cout << lo << endl;
  return 0;
}
