#include <bits/stdc++.h>
using namespace std;
const int maxn = 10010;
int h[maxn], b[maxn], id[maxn], n, l, r, s;
bool cmp(const int &x, const int &y) {
  return b[x] == b[y] ? h[x] > h[y] : b[x] < b[y];
}
int f[2][maxn], g[maxn];
int main() {
  scanf("%d%d%d", &n, &l, &r);
  for (register int i = 1; i <= n; ++i) {
    scanf("%d", &h[i]);
    s += h[i];
  }
  for (register int i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
    id[i] = i;
  }
  sort(id + 1, id + 1 + n, cmp);
  g[0] = 1;
  for (register int i = 1; i <= n; ++i) {
    memset(f[i & 1], 0, sizeof(f[i & 1]));
    for (register int H = s - h[id[i]]; ~H; --H)
      if (g[H]) {
        g[H + h[id[i]]] = 1;
        if (b[id[i]] && H + h[id[i]] >= s - r && H + h[id[i]] <= s - l) {
          f[i & 1][H + h[id[i]]] =
              max(f[i & 1][H + h[id[i]]], f[i & 1 ^ 1][H] + 1);
        }
      }
    for (register int H = 1; H <= s; ++H)
      f[i & 1][H] = max(f[i & 1][H], max(f[i & 1 ^ 1][H], f[i & 1][H - 1]));
  }
  printf("%d\n", f[n & 1][s]);
  return 0;
}
