#include <bits/stdc++.h>
using namespace std;
const long long inf = 4e18;
const double eps = 1e-9;
const int N = 10540;
int n, a[N], b[N];
bitset<N> dp;
int l, r;
bitset<N> f[N];
int can[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> l >> r;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  vector<int> important, bad;
  for (int i = 1; i <= n; ++i) {
    if (b[i])
      important.push_back(a[i]);
    else
      bad.push_back(a[i]);
  }
  int sz = bad.size();
  dp[0] = 1;
  for (int i = 1; i <= sz; ++i) dp |= (dp << bad[i - 1]);
  sort(important.begin(), important.end());
  sz = important.size();
  f[sz + 1] = dp;
  for (int k = sz; k >= 1; --k)
    f[k] = (f[k + 1] | (f[k + 1] << important[k - 1]));
  int sum = 0;
  can[0] = 0;
  int ans = 0;
  for (int k = 1; k <= sz; ++k) {
    int h = important[k - 1];
    int pos = 0;
    for (int j = 0; j <= sum; ++j) {
      if (!can[j] && j > 0) continue;
      int other = sum - j;
      while (pos < l - other || !f[k + 1][pos] && pos + j + other <= r) pos++;
      if (pos + other >= l && pos + other + j <= r && f[k + 1][pos])
        ans = max(ans, can[j] + 1);
    }
    sum += h;
    for (int j = sum - h; j >= 0; --j)
      if (can[j] || j == 0) {
        can[j + h] = max(can[j + h], can[j] + 1);
      }
  }
  cout << ans;
  return 0;
}
