#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 5;
int n, c;
int p[MAXN], s[MAXN];
long long f[2][MAXN];
int main() {
  scanf("%d%d", &n, &c);
  for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &s[i]);
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      f[i & 1][j] = f[i & 1 ^ 1][j] + p[i] + (long long)j * c;
      if (j) f[i & 1][j] = min(f[i & 1][j], f[i & 1 ^ 1][j - 1] + s[i]);
    }
  }
  for (int i = 1; i <= n; ++i) f[n & 1][0] = min(f[n & 1][0], f[n & 1][i]);
  printf("%lld\n", f[n & 1][0]);
  return 0;
}
