#include <bits/stdc++.h>
using namespace std;
bool SR(int &_x) { return scanf("%d", &_x) == 1; }
bool SR(long long &_x) { return scanf("%lld", &_x) == 1; }
bool SR(double &_x) { return scanf("%lf", &_x) == 1; }
bool SR(char *_s) { return scanf("%s", _s) == 1; }
bool RI() { return true; }
template <typename I, typename... T>
bool RI(I &_x, T &..._tail) {
  return SR(_x) && RI(_tail...);
}
void SP(const int _x) { printf("%d", _x); }
void SP(const long long _x) { printf("%lld", _x); }
void SP(const double _x) { printf("%.16lf", _x); }
void SP(const char *s) { printf("%s", s); }
void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I _x, const T... _tail) {
  SP(_x);
  if (sizeof...(_tail)) putchar(' ');
  PL(_tail...);
}
const int maxn = 1e4 + 4;
int n;
long long c;
long long s[maxn], t[maxn];
void read() {
  RI(n, c);
  for (int i = (1); i <= int(n); i++) RI(s[i]);
  for (int i = (1); i <= int(n); i++) RI(t[i]);
}
long long w[maxn];
void build() {
  for (int i = (1); i <= int(n); i++) w[i] = s[i] - t[i] + i * c;
  sort(w + 1, w + n + 1);
}
void sol() {
  long long ans = accumulate(t + 1, t + n + 1, 0LL);
  long long cur = ans;
  for (int j = (1); j <= int(n); j++) {
    cur += w[j] - j * c;
    ans = min(ans, cur);
  }
  PL(ans);
}
int main() {
  read();
  build();
  sol();
  return 0;
}
