#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();
  return data * w;
}
long long n, c, p[1000005], a[1000005];
int main() {
  n = read(), c = read();
  for (long long i = 1; i <= n; i++) p[i] = read();
  long long sum = 0, ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long s = read();
    a[i] = s - p[i] + c * (n - i);
    sum += p[i];
  }
  ans = sum;
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n; i++)
    sum += a[i] - (i - 1) * c, ans = min(ans, sum);
  cout << ans << '\n';
  return 0;
}
