#include <bits/stdc++.h>
using namespace std;
const int N = 10001;
int n, c[N], b[N], w[N], l, r, cnt, sum;
bitset<N> f, g, t;
int main() {
  scanf("%d%d%d", &n, &l, &r);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (b[i]) c[++cnt] = w[i], sum += w[i];
  }
  sort(c + 1, c + 1 + cnt);
  f[0] = 1;
  for (int i = 1; i <= n; i++)
    if (!b[i]) f |= f << w[i];
  for (int i = cnt; i >= 1; i--) {
    g |= g << c[i];
    g |= f;
    f |= f << c[i];
    sum -= c[i];
    t = g;
    t <<= 10000 - r + sum;
    t >>= 10000 - r + sum + l;
    if (t.count()) {
      printf("%d\n", i);
      return 0;
    }
  }
  puts("0");
  return 0;
}
