#include <bits/stdc++.h>
using namespace std;
long long n, c, b, a[10004], cur, ans;
priority_queue<long long> pq;
int main() {
  cin >> n >> c;
  for (int i = 0; i < n; ++i) cin >> a[i];
  cur = accumulate(a, a + n, 0ll), ans = cur;
  for (int i = 0; i < n; ++i) cin >> b, pq.push(a[i] - b - (n - i - 1) * c);
  for (int i = 0; i < n; ++i)
    cur -= pq.top() + i * c, pq.pop(), ans = min(ans, cur);
  cout << ans << '\n';
}
