#include <bits/stdc++.h>
using namespace std;
int n, l, r;
int main() {
  cin >> n >> l >> r;
  vector<int> a(n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s += a[i];
  }
  r = min(r, s);
  vector<int> used;
  vector<int> rev;
  for (int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    (b ? used : rev).push_back(a[i]);
  }
  sort(used.begin(), used.end());
  vector<int> dp(s + 1);
  int cur = 0;
  dp[0] = 1;
  bool pb = false;
  auto add = [&](int v) {
    cur += v;
    for (int i = s; i > v - 1; i--) {
      if (dp[i - v]) {
        if (pb)
          dp[i] = 2;
        else
          dp[i] = 1;
      }
    }
  };
  for (auto i : rev) add(i);
  pb = true;
  for (int i = l; i < cur - r + 1; i++) {
    if (dp[i]) {
      cout << used.size() << endl;
      return 0;
    }
  }
  while (used.size()) {
    int b = used.back();
    used.pop_back();
    add(b);
    for (int i = s - r; i < cur - l + 1; i++) {
      if (dp[i] == 2) {
        cout << used.size() + 1 << endl;
        return 0;
      }
    }
  }
  cout << 0;
  return 0;
}
