#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 7;
int n, l, r, s, Mx, dp[2][N];
pair<int, int> A[N];
int main() {
  scanf("%d%d%d", &n, &l, &r);
  for (int i = 0; i < n; i++) scanf("%d", &A[i].second), s += A[i].second;
  for (int i = 0; i < n; i++) scanf("%d", &A[i].first), A[i].first ^= 1;
  swap(l, r);
  r = s - r;
  l = s - l;
  sort(A, A + n);
  reverse(A, A + n);
  for (int j = 1; j < N; j++) dp[0][j] = dp[1][j] = -1;
  for (int i = 0, w = 0; i < n; i++, w = !w) {
    for (int j = 1; j < N; j++) dp[w][j] = max(dp[w][j], dp[!w][j]);
    for (int j = 0; j < N; j++)
      if (j + A[i].second < N && dp[!w][j] != -1)
        dp[w][j + A[i].second] =
            max(dp[w][j + A[i].second],
                dp[!w][j] + (!A[i].first && l <= j + A[i].second &&
                             j + A[i].second <= r));
  }
  for (int i = 0; i < N; i++) Mx = max(Mx, dp[(n - 1) & 1][i]);
  return !printf("%d", Mx);
}
