#include <bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int dp[10001];
bool was[10001];
int sum = 0;
int n;
pair<int, int> arr[10001];
bool cmp(pii a, pii b) {
  return (a.second < b.second || (a.second == b.second && a.first > b.first));
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int l, r;
  cin >> n >> l >> r;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i].first;
    sum += arr[i].first;
  }
  for (int i = 0; i < n; ++i) cin >> arr[i].second;
  sort(arr, arr + n, cmp);
  was[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = sum; j >= arr[i].first; --j) {
      if (!was[j - arr[i].first]) continue;
      was[j] = 1;
      dp[j] = max(dp[j], dp[j - arr[i].first] +
                             (arr[i].second && j >= sum - r && j <= sum - l));
    }
  }
  int ma = 0;
  for (int i = 0; i <= 10000; ++i) ma = max(ma, dp[i]);
  cout << ma;
  return 0;
}
