#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, l, r, a[N], dp[N];
vector<int> key, oth;
int main() {
  cin >> n >> l >> r;
  int sum = 0;
  for (int i = 1; i <= n; i++) a[i] = gi(), sum += a[i];
  l = sum - l;
  r = sum - r;
  swap(l, r);
  if (r < 0) return cout << 0, 0;
  for (int i = 1; i <= n; i++) (gi() ? key : oth).push_back(a[i]);
  memset(dp, 0xc0, sizeof(dp));
  dp[0] = 0;
  for (auto x : oth)
    for (int i = r - x; i >= 0; i--) dp[i + x] = max(dp[i + x], dp[i]);
  sort(key.begin(), key.end(), greater<int>());
  for (auto x : key)
    for (int i = r - x; i >= 0; i--)
      dp[i + x] = max(dp[i + x], dp[i] + (i + x >= l));
  cout << *max_element(dp, dp + r + 1);
  return 0;
}
