#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
vector<int> a[2];
int t[N];
bitset<N> dp[2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, l, r;
  cin >> n >> l >> r;
  for (int i = 0; (i) < (n); ++i) {
    cin >> t[i];
  }
  for (int i = 0; (i) < (n); ++i) {
    int b;
    cin >> b;
    a[b].push_back(t[i]);
  }
  sort((a[0]).begin(), (a[0]).end());
  sort((a[1]).begin(), (a[1]).end());
  dp[0][0] = 1;
  for (int x : a[0]) {
    dp[0] |= (dp[0] << x);
  }
  int sum = 0;
  int now = 0;
  for (int x : a[1]) {
    sum += x;
    now++;
  }
  if (now == 0) {
    cout << 0 << '\n';
    return 0;
  }
  int best = 0;
  reverse((a[1]).begin(), (a[1]).end());
  for (int x : a[1]) {
    int start = r - sum;
    if (start >= l) {
      for (int j = (l); (j) < (start + 1); ++j) {
        if (dp[0][j] == 1) {
          best = max(best, now);
        }
        if (dp[1][j] == 1) {
          best = max(best, now + 1);
        }
      }
    }
    dp[1] = dp[0] | (dp[1] << x);
    dp[0] |= (dp[0] << x);
    sum -= x;
    now--;
  }
  for (int j = (l); (j) < (r + 1); ++j) {
    if (dp[1][j]) best = max(best, 1);
  }
  cout << best << '\n';
  return 0;
}
