#include <bits/stdc++.h>
using namespace std;
void doRoutine() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
long long n, l, r;
const long long MAXN = 10005;
long long a[MAXN];
long long b[MAXN];
long long ids[MAXN];
long long H = 0;
bool cmp_ids(long long i, long long j) {
  if (b[i] != b[j]) {
    return b[i] < b[j];
  } else if (a[i] != a[j]) {
    return a[i] > a[j];
  } else {
    return i < j;
  }
}
const long long MAXH = 10005;
long long dp[MAXH];
long long tmp[MAXH];
signed main() {
  doRoutine();
  cin >> n >> l >> r;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    H += a[i];
    ids[i] = i;
  }
  for (long long i = 0; i < n; ++i) {
    cin >> b[i];
  }
  long long nl = H - r;
  long long nr = H - l;
  l = nl, r = nr;
  sort(ids, ids + n, cmp_ids);
  for (long long i = 0; i <= r; ++i) {
    dp[i] = 0;
  }
  bitset<MAXH> used;
  used.set(0);
  used[0] = 1;
  for (long long i = 0; i < n; ++i) {
    long long id = ids[i];
    for (long long j = 0; j <= r; ++j) {
      tmp[j] = dp[j];
    }
    for (long long x = 0; x <= r; ++x) {
      dp[x] = tmp[x];
      if (a[id] <= x && used[x - a[id]]) {
        dp[x] = max(dp[x], tmp[x - a[id]] + (b[id] && x >= l));
      }
    }
    used = used | (used << a[id]);
  }
  long long ans = 0;
  for (long long i = 0; i <= r; ++i) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}
