#include <bits/stdc++.h>
using namespace std;
int n, l, r, a[10004], h, dp[10004];
bool b;
vector<int> v[2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> l >> r;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    h += a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> b;
    v[b].push_back(a[i]);
  }
  sort(v[1].begin(), v[1].end());
  reverse(v[1].begin(), v[1].end());
  for (int i = 0; i < h; ++i) dp[i] = -1;
  for (int i = 0; i < v[0].size(); ++i) {
    for (int j = v[0][i]; j <= h; ++j) {
      if (dp[j] != -1) dp[j - v[0][i]] = 0;
    }
  }
  for (int i = 0; i < v[1].size(); ++i) {
    for (int j = v[1][i]; j <= h; ++j) {
      if (dp[j] != -1) {
        dp[j - v[1][i]] = max(dp[j - v[1][i]], dp[j] + (int)(j - v[1][i] >= l &&
                                                             j - v[1][i] <= r));
      }
    }
  }
  int fp = 0;
  for (int i = 0; i <= h; ++i) {
    fp = max(fp, dp[i]);
  }
  cout << fp << endl;
  return 0;
}
