#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long t = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') t = t * 10 + c - 48, c = getchar();
  return t * f;
}
long long n, m, del, hf, tot, num[2001], dp[1201][12002], cost[2001];
int main() {
  n = read();
  m = read();
  del = read();
  hf = read();
  for (register int i = 1; i <= n; ++i) num[i] = read(), tot += num[i];
  for (register int i = 1; i <= n; ++i) cost[i] = read();
  for (register int i = 0; i <= n + 1; ++i)
    for (register int j = 0; j <= tot; ++j) dp[i][j] = -1e17;
  dp[1][0] = m;
  for (register int i = 1; i <= n; ++i) {
    for (register int j = 0; j <= tot; ++j)
      for (register int t = 0;
           t <= min(num[i], cost[i] == 0 ? (10000000) : dp[i][j] / cost[i]);
           ++t)
        dp[i + 1][j + t] =
            max(dp[i + 1][j + t],
                min(m + (j + t) * del, dp[i][j] - t * cost[i] + hf));
  }
  for (register int j = tot; j >= 0; --j)
    if (dp[n + 1][j] >= 0) {
      cout << j << endl;
      return 0;
    }
}
