#include <bits/stdc++.h>
using namespace std;
struct point {
  int a;
  int b;
} x[20052];
bool cmp(point x, point y) {
  if (x.b == y.b) return x.a > y.a;
  return x.b < y.b;
}
int dp[2][20052], n, l, r;
int main() {
  scanf("%d%d%d", &n, &l, &r);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i].a);
    sum += x[i].a;
  }
  int t = l;
  l = sum - r;
  r = sum - t;
  for (int i = 1; i <= n; i++) scanf("%d", &x[i].b);
  sort(x + 1, x + n + 1, cmp);
  dp[0][0] = 0;
  for (int i = 1; i < 20052; i++) {
    dp[0][i] = -n;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 20052; j++) {
      if (j >= x[i].a) {
        dp[i & 1][j] =
            max(dp[(i - 1) & 1][j],
                dp[(i - 1) & 1][j - x[i].a] +
                    (((x[i].b == 1) && (j <= r) && (j >= l)) ? 1 : 0));
      } else
        dp[i & 1][j] = dp[(i - 1) & 1][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < 20052; i++) {
    ans = max(ans, dp[n & 1][i]);
  }
  printf("%d\n", ans);
  return 0;
}
