#include <bits/stdc++.h>
using namespace std;
bitset<10001> can;
int main() {
  int n, l, r;
  cin >> n >> l >> r;
  int w[n];
  int imp[n];
  int h = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", w + i);
    h += w[i];
  }
  int t = l;
  l = h - r;
  r = h - t;
  for (int i = 0; i < n; i++) {
    scanf("%d", imp + i);
  }
  int imp_n, non_n;
  imp_n = non_n = 0;
  int a_imp[10001], a_non[10001];
  for (int i = 0; i < n; i++) {
    if (imp[i]) {
      a_imp[imp_n++] = w[i];
    } else {
      a_non[non_n++] = w[i];
    }
  }
  can[0] = 1;
  for (int i = 0; i < non_n; i++) {
    can |= can << a_non[i];
  }
  sort(a_imp, a_imp + n, [](const int& a, const int& b) { return b < a; });
  int val[2][10001] = {0};
  for (int i = 0; i < imp_n; i++) {
    for (int j = 0; j <= 10000; j++) {
      if (can[j]) {
        val[i & 1][j + a_imp[i]] =
            max(val[i & 1 ^ 1][j + a_imp[i]],
                val[i & 1 ^ 1][j] +
                    (a_imp[i] + j >= l && a_imp[i] + j <= r ? 1 : 0));
      }
    }
    can |= can << a_imp[i];
  }
  int mx = 0;
  for (int i = 0; i < 10000; i++) {
    mx = max(mx, val[(imp_n - 1) & 1][i]);
  }
  cout << mx;
  return 0;
}
