#include <bits/stdc++.h>
using namespace std;
int n, l, r, sum, dp[10010];
pair<int, int> a[10010];
inline int cmp(pair<int, int> x, pair<int, int> y) {
  return x.first == y.first ? x.second > y.second : x.first < y.first;
}
int main() {
  scanf("%d%d%d", &n, &l, &r);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].second), sum += a[i].second;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].first);
  r = sum - r;
  l = sum - l;
  swap(l, r);
  sort(a + 1, a + n + 1, cmp);
  fill(dp + 1, dp + sum + 1, -1e9);
  for (int i = 1; i <= n; i++) {
    for (int j = sum; j >= a[i].second; j--) {
      dp[j] = max(dp[j],
                  dp[j - a[i].second] + (a[i].first == 1 && j >= l && j <= r));
    }
  }
  int ans = 0;
  for (int i = 0; i <= sum; i++) ans = max(ans, dp[i]);
  printf("%d\n", ans);
  return 0;
}
