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