#include <bits/stdc++.h>
using namespace std;
long long n;
long long c;
long long p[20010];
long long s[20010];
long long sum;
long long a[20010];
signed main() {
  scanf("%lld%lld", &n, &c);
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &p[i]);
    sum += p[i];
  }
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &s[i]);
    a[i] = (n - i) * c - p[i] + s[i];
  }
  sort(a + 1, a + 1 + n);
  long long ans = sum;
  for (long long i = 1; i <= n; ++i) {
    sum = sum + a[i] - (i - 1) * c;
    ans = min(ans, sum);
  }
  printf("%lld\n", ans);
}
