#include <bits/stdc++.h>
template <typename T>
inline bool MIN(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool MAX(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
using namespace std;
int n, m, A[10010], B[10010];
long long f[2][10010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &B[i]);
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    memset(f[i & 1], 0x3f, sizeof(f[i & 1]));
    for (int j = 0; j < i; ++j) {
      MIN(f[i & 1][j + 1], f[(i - 1) & 1][j] + B[i]);
      MIN(f[i & 1][j], f[(i - 1) & 1][j] + A[i] + (long long)j * m);
    }
  }
  for (int i = n; i; --i) MIN(f[n & 1][i - 1], f[n & 1][i]);
  printf("%I64d\n", f[n & 1][0]);
  return 0;
}
