#include <bits/stdc++.h>
using namespace std;
const long long K = 10001;
signed main() {
  long long n, l, r, ans = 0;
  cin >> n >> l >> r;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  vector<long long> bad, good;
  for (long long i = 0; i < n; i++) {
    if (b[i] == 0)
      bad.push_back(a[i]);
    else
      good.push_back(a[i]);
  }
  if (good.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(good.begin(), good.end());
  long long S = 0;
  for (long long i = 0; i < good.size(); i++) S += good[i];
  bool knapbad[K], knapgood[K];
  for (long long i = 0; i < K; i++) knapbad[i] = false;
  for (long long i = 0; i < K; i++) knapgood[i] = false;
  knapbad[0] = true;
  knapgood[0] = true;
  for (long long i = 0; i < bad.size(); i++) {
    for (long long j = K - 1; j >= bad[i]; j--)
      knapbad[j] |= knapbad[j - bad[i]];
  }
  long long pref[K + 1];
  pref[0] = 0;
  for (long long i = 1; i <= K; i++) pref[i] = pref[i - 1] + knapbad[i - 1];
  vector<vector<long long> > close(good.size());
  long long INF = 1e9;
  close[good.size() - 1].push_back(0);
  for (long long i = good.size() - 1; i >= 0; i--) {
    for (long long j = K - 1; j >= good[i]; j--) {
      if (!knapgood[j] && knapgood[j - good[i]]) {
        if (i != 0) close[i - 1].push_back(j);
        knapgood[j] = true;
      }
    }
  }
  for (long long i = l; i <= r; i++)
    if (knapgood[i] && i != S) ans = max(ans, (long long)1);
  long long Kn[K];
  for (long long i = 0; i < K; i++) Kn[i] = -INF;
  Kn[0] = 0;
  for (long long i = 0; i < good.size(); i++) {
    for (long long j = K - 1; j >= good[i]; j--) {
      Kn[j] = max(Kn[j], Kn[j - good[i]] + 1);
    }
    for (long long j = 0; j < close[i].size(); j++) {
      long long N = close[i][j];
      for (long long p = 0; p < K; p++) {
        if (Kn[p] < 0) continue;
        long long L = max((long long)0, l - N), R = r - N - p;
        if (L > R) continue;
        if (pref[R + 1] - pref[L] == 0) continue;
        if (N + p == S)
          ans = max(ans, Kn[p]);
        else
          ans = max(ans, Kn[p] + 1);
      }
    }
  }
  cout << ans;
}
