#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 6;
int n, l, r, h[N], b[N], ans[N], S;
vector<int> X, Y;
int main() {
  scanf("%d%d%d", &n, &l, &r);
  for (int i = 1; i <= n; ++i) scanf("%d", h + i), S += h[i];
  for (int i = 1; i <= n; ++i) scanf("%d", b + i);
  int _l = S - r, _r = S - l;
  for (int i = 1; i <= n; ++i) (b[i] ? Y : X).push_back(h[i]);
  sort(X.rbegin(), X.rend()), sort(Y.rbegin(), Y.rend());
  for (int i = 1; i <= 10000; ++i) ans[i] = -1e9;
  for (int s : X)
    for (int i = 10000; i >= s; --i)
      if (ans[i - s] >= 0) ans[i] = max(ans[i], ans[i - s]);
  for (int s : Y)
    for (int i = 10000; i >= s; --i)
      if (ans[i - s] >= 0)
        ans[i] = max(ans[i], ans[i - s] + (_l <= i && i <= _r));
  printf("%d\n", *max_element(ans, ans + 10001));
}
