#include <bits/stdc++.h>
using namespace std;
const int maxn = 10010, inf = 0x7ffffff;
int n, L, R, maxx, f[maxn], ans;
struct node {
  int x, y;
} e[maxn];
bool cmp(node a, node b) {
  if (a.x == b.x) return a.y > b.y;
  return a.x < b.x;
}
int main() {
  scanf("%d%d%d", &n, &L, &R);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &e[i].y);
    maxx += e[i].y;
  }
  L = maxx - L, R = maxx - R;
  swap(L, R);
  for (int i = 1; i <= n; i++) scanf("%d", &e[i].x);
  sort(e + 1, e + 1 + n, cmp);
  for (int i = 0; i <= maxx; i++) f[i] = -inf;
  f[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = R; j >= e[i].y; j--) {
      int temp = 0;
      if (e[i].x == 1 && j >= L && j <= R) temp = 1;
      f[j] = max(f[j], f[j - e[i].y] + temp);
    }
    for (int j = L; j <= R; j++) ans = max(ans, f[j]);
  }
  printf("%d\n", ans);
  return 0;
}
