#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:250000000")
template <typename T>
int size(T& a) {
  return (int)a.size();
}
template <typename T>
T sqr(T a) {
  return a * a;
}
int d[1001];
int s[1001];
int dp[2][1000 * 1000 + 1010];
void up(int& a, int b) {
  if (a == -1 || a > b) a = b;
}
int main() {
  int m, k;
  cin >> m >> k;
  for (int i = (0), _up = (int)m; i < _up; ++i) cin >> d[i];
  for (int i = (0), _up = (int)m; i < _up; ++i) cin >> s[i];
  memset((dp), (255), sizeof(dp));
  dp[0][s[0]] = 0;
  int curs = 0;
  for (int i = (0), _up = (int)m; i < _up; ++i) curs += d[i];
  for (int i = (0), _up = (int)m; i < _up; ++i) {
    int j = i & 1;
    int tj = 1 - j;
    memset((dp[tj]), (255), sizeof(dp[tj]));
    for (int z = (0), _up = (int)curs + 1001; z < _up; ++z) {
      if (dp[j][z] == -1) continue;
      if (z + s[i] <= curs + 1001) up(dp[j][z + s[i]], dp[j][z] + k);
      if (z >= d[i]) {
        up(dp[tj][z - d[i] + s[i + 1]], dp[j][z] + d[i]);
      }
    }
    curs -= d[i];
  }
  int ans = -1;
  for (int i = (0), _up = (int)1000 * 1000 + 1001; i < _up; ++i)
    if (dp[m & 1][i] != -1) up(ans, dp[m & 1][i]);
  cout << ans;
}
