#include <bits/stdc++.h>
inline int pidorand() { return ((rand() & 32767) << 15) | (rand() & 32767); }
using namespace std;
inline int nxt() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 11111;
char knap[N];
int crucial[N];
int timer = 0;
int main() {
  int n = nxt(), l = nxt(), r = nxt();
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    a[i] = nxt();
  }
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    b[i] = nxt();
  }
  vector<int> imp, shit;
  for (int i = 0; i < n; ++i) {
    (b[i] ? imp : shit).push_back(a[i]);
  }
  sort((imp).begin(), (imp).end());
  sort((shit).begin(), (shit).end());
  map<int, int> M;
  for (int x : shit) {
    M[x] += 1;
    while (M[x] > 2) {
      M[x] -= 2;
      x *= 2;
      M[x] += 1;
    }
  }
  shit.clear();
  for (auto p : M) {
    for (int i = 0; i < p.second; ++i) {
      shit.push_back(p.first);
    }
  }
  knap[0] = 1;
  int mx = 0;
  for (int x : shit) {
    for (int i = mx; i >= 0; --i) {
      if (knap[i]) {
        knap[i + x] = 1;
      }
    }
    mx += x;
  }
  int cur = l;
  while (cur <= r && !knap[cur]) {
    ++cur;
  }
  int cur_nc = cur;
  vector<int> pr_sums(imp.size() + 1);
  for (int i = 0; i < (int)imp.size(); ++i) {
    pr_sums[i + 1] = pr_sums[i] + imp[i];
  }
  int ans = 0;
  for (int i = (int)imp.size() - 1; i >= 0; --i) {
    ++timer;
    int x = imp[i];
    for (int j = mx; j >= 0; --j) {
      if (knap[j]) {
        if (!knap[j + x] && crucial[j] == timer - 1) {
          crucial[j + x] = timer;
        }
        knap[j + x] = 1;
        if (j + x >= l && j + x < cur) {
          cur = j + x;
        }
        if (j + x >= l && j + x < cur_nc && crucial[j + x] < timer) {
          cur_nc = j + x;
        }
      }
    }
    mx += x;
    int len = r - cur;
    int cnt = min<int>(upper_bound((pr_sums).begin(), (pr_sums).end(), len) -
                           pr_sums.begin(),
                       i + 1) -
              1;
    ans = max(ans, cnt);
    len = r - cur_nc;
    cnt = min<int>(upper_bound((pr_sums).begin(), (pr_sums).end(), len) -
                       pr_sums.begin(),
                   i + 1) -
          1;
    if (len >= 0) {
      ans = max(ans, cnt + 1);
    }
  }
  printf("%d\n", ans);
  return 0;
}
