#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 10100;
int n, l, r;
vector<int> a[2];
int aa[N];
void calc(const vector<int>& a, vector<vector<int> >& d) {
  d.resize(2);
  int sum = 0;
  for (int i = int(0); i < int(((int)(a).size())); ++i) {
    sum += a[i];
  }
  for (int i = int(0); i < int(2); ++i) d[i].assign(sum + 1, 0);
  d[0][0] = 1;
  for (int i = int(0); i < int(((int)(a).size())); ++i) {
    int i0 = (i & 1), i1 = (i0 ^ 1);
    for (int j = int(0); j < int(sum); ++j) {
      if (d[i0][j]) {
        d[i1][j + a[i]] = 1;
        d[i1][j] = 1;
      }
    }
  }
  for (int i = int(0); i < int(sum + 1); ++i) {
    d[0][i] = max(d[0][i], d[1][i]);
  }
}
unsigned long long dmax[N][200];
int dkol[2][N];
int tekkol[N];
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  cin >> n >> l >> r;
  for (int i = int(0); i < int(n); ++i) {
    cin >> aa[i];
  }
  for (int i = int(0); i < int(n); ++i) {
    int tp;
    cin >> tp;
    a[tp].push_back(aa[i]);
  }
  sort((a[0]).begin(), (a[0]).end());
  sort((a[1]).begin(), (a[1]).end());
  vector<vector<int> > d0;
  calc(a[0], d0);
  int sum0 = 0;
  for (int i = int(0); i < int(((int)(a[0]).size())); ++i) {
    sum0 += a[0][i];
  }
  int ans = 0;
  vector<int> lpos;
  for (int i = int(0); i < int(sum0 + 1); ++i) {
    if (d0[0][i]) {
      if (i < l) {
        lpos.push_back(l - i);
      } else {
        int tek = i;
        int res = 0;
        for (int j = int(0); j < int(((int)(a[1]).size())); ++j) {
          if (tek > r) {
            break;
          }
          ++res;
          tek += a[1][j];
        }
        umx(ans, res);
        break;
      }
    }
  }
  memset(dmax, 0, sizeof(dmax));
  dmax[0][0] = 1ull;
  int sum1 = 0;
  for (int i = int(0); i < int(((int)(a[1]).size())); ++i) {
    sum1 += a[1][i];
  }
  for (int i = int(0); i < int(((int)(a[1]).size())); ++i) {
    for (int j = int(0); j < int(sum1 + 1); ++j) {
      if (dmax[i][j >> 6] & (1ull << (j & 63))) {
        int idx = (j + a[1][((int)(a[1]).size()) - i - 1]);
        dmax[i + 1][idx >> 6] |= (1ull << (idx & 63));
      }
      if (!(j & 63)) {
        dmax[i + 1][j >> 6] |= dmax[i][j >> 6];
      }
    }
  }
  for (int i = int(0); i < int(sum1 + 1); ++i) {
    if (dmax[((int)(a[1]).size())][i >> 6] & (1ull << (i & 63))) {
      if (i >= l && i <= r && sum1 != i) {
        umx(ans, 1);
      }
    }
  }
  memset(dkol, -1, sizeof(dkol));
  dkol[0][0] = 0;
  sort((lpos).begin(), (lpos).end());
  ;
  for (int i = int(0); i < int(((int)(a[1]).size())); ++i) {
    int i0 = (i & 1), i1 = (i0 ^ 1);
    for (int j = int(0); j < int(sum1 + 1); ++j) {
      if (dkol[i0][j] < 0) continue;
      umx(dkol[i1][j + a[1][i]], dkol[i0][j] + 1);
      umx(dkol[i1][j], dkol[i0][j]);
    }
    memset(tekkol, -1, sizeof(tekkol));
    tekkol[0] = 0;
    for (int j = int(1); j < int(N); ++j) {
      tekkol[j] = max(tekkol[j - 1], dkol[i1][j]);
    }
    int t = 0;
    for (int j = int(0); j < int(((int)(lpos).size())); ++j) {
      while (t <= sum1 &&
             ((t < lpos[j]) || (!(dmax[((int)(a[1]).size()) - i - 1][t >> 6] &
                                  (1ull << (t & 63))))))
        ++t;
      if (t > sum1) {
        break;
      }
      if (r - l - (t - lpos[j]) >= 0 && r - l - (t - lpos[j]) < N) {
        int tekres = tekkol[r - l - (t - lpos[j])];
        if (sum1 > lpos[j] + (r - l)) {
          ++tekres;
        }
        umx(ans, tekres);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
