#include <bits/stdc++.h>
using namespace std;
long long n, m, f[100001], p[100001], w[100001], ans, s;
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1ll; i <= n; i++) {
    scanf("%lld", &f[i]);
    s = s + f[i];
  }
  for (long long i = 1ll; i <= n; i++) {
    scanf("%lld", &p[i]);
    w[i] = p[i] + (n - i) * m - f[i];
  }
  sort(w + 1ll, w + n + 1ll);
  ans = s;
  for (long long i = 1ll; i <= n; i++) {
    s = s + w[i] - (i - 1ll) * m;
    ans = min(ans, s);
  }
  printf("%lld\n", ans);
}
