#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 10;
int n, arr[MAXN], l, r, newl, newr, total;
int dp[MAXN], id[MAXN];
bool imp[MAXN];
bool cmp(const int &l, const int &r) {
  if (imp[l] != imp[r]) return imp[r];
  return arr[l] > arr[r];
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> l >> r;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    total += arr[i];
    id[i] = i;
  }
  for (int i = 0; i < n; i++) cin >> imp[i];
  newl = total - r;
  newr = total - l;
  memset(dp, 128, sizeof(dp));
  dp[0] = 0;
  sort(id, id + n, cmp);
  for (int i = 0; i < n; i++) {
    for (int j = total - arr[id[i]]; ~j; j--) {
      int val = 0;
      if (imp[id[i]] && (j + arr[id[i]]) <= newr && (j + arr[id[i]]) >= newl)
        val = 1;
      dp[j + arr[id[i]]] = max(dp[j] + val, dp[j + arr[id[i]]]);
    }
  }
  int answer = 0;
  for (int i = 0; i <= total; i++) answer = max(answer, dp[i]);
  cout << answer << '\n';
  return 0;
}
