#include <bits/stdc++.h>
const int maxn = 1e3 + 3, maxsc = 1e4 + 3;
int n, cap[maxn], scap;
long long W, B, X, cost[maxn], dp[2][maxsc];
int main() {
  scanf("%d%lld%lld%lld", &n, &W, &B, &X);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", cap + i);
    scap += cap[i];
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", cost + i);
  }
  memset(dp[0], 0x80, sizeof(long long) * (scap + 1));
  dp[0][0] = W - X;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    long long *a = dp[i & 1], *b = dp[~i & 1];
    memset(a, 0x80, sizeof(long long) * (scap + 1));
    std::deque<std::pair<long long, int>> q;
    for (long long j = 0; j <= scap; ++j) {
      while (!q.empty() &&
             q.back().first <= std::min(b[j] + X, W + j * B) + j * cost[i])
        q.pop_back();
      q.push_back({std::min(b[j] + X, W + j * B) + j * cost[i], j});
      while (!q.empty() && j - q.front().second > cap[i]) q.pop_front();
      if (q.front().first - j * cost[i] >= 0) {
        a[j] = q.front().first - j * cost[i];
        ans = std::max(ans, (int)j);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
