#include <bits/stdc++.h>
using namespace std;
vector<int> a, b, order;
bool comp(int i, int j) {
  return ((b[i] == b[j]) ? (a[i] > a[j]) : (b[i] < b[j]));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, l, r, ans = 0;
  cin >> n >> l >> r;
  l++;
  r++;
  int sum = 0;
  a.resize(n);
  b.resize(n);
  order.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) order[i] = i;
  sort(order.begin(), order.end(), comp);
  vector<vector<int> > dp(2, vector<int>(sum + 1, -1));
  dp[0][sum] = 0;
  for (int i = 0; i <= n; i++) {
    fill(dp[(i + 1) % 2].begin(), dp[(i + 1) % 2].end(), -1);
    for (int j = sum; j >= 0; j--) {
      if (dp[i % 2][j] == -1) continue;
      ans = max(ans, dp[i % 2][j]);
      if (i < n) {
        dp[(i + 1) % 2][j] = max(dp[(i + 1) % 2][j], dp[i % 2][j]);
        int addOn = 0, v = order[i];
        if (j - a[v] + 1 >= l && j - a[v] + 1 <= r && b[v] == 1) addOn++;
        dp[(i + 1) % 2][j - a[v]] =
            max(dp[(i + 1) % 2][j - a[v]], dp[i % 2][j] + addOn);
      }
    }
  }
  cout << ans;
  return 0;
}
