#include <bits/stdc++.h>
const int maxn = 10002;
const int maxl = 20002;
bool can_g[maxn][maxl];
bool can_b[maxl];
int ans[maxl];
using namespace std;
int main() {
  int n = 0;
  int l, r;
  cin >> n >> l >> r;
  vector<int> a(n, 0);
  vector<int> bq(n, 0);
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> bq[i];
  }
  vector<int> g, b;
  for (int i = 0; i < n; i++) {
    if (bq[i]) {
      g.push_back(a[i]);
    } else {
      b.push_back(a[i]);
    }
  }
  sort(g.begin(), g.end(), greater<int>());
  can_b[s] = true;
  for (int x : b) {
    for (int i = 0; i + x <= s; ++i) {
      can_b[i] |= can_b[i + x];
    }
  }
  for (int i = 0; i <= s; ++i) {
    if (!can_b[i]) {
      ans[i] = -n;
    }
  }
  for (auto w : g) {
    for (int i = 0; i + w <= s; ++i) {
      int fl = 0;
      if (l <= i && i <= r) {
        fl = 1;
      }
      ans[i] = max(ans[i], ans[i + w] + fl);
    }
  }
  int r_ans = 0;
  for (int i = 0; i <= s; ++i) {
    r_ans = max(r_ans, ans[i]);
  }
  cout << r_ans;
  return 0;
}
