#include <bits/stdc++.h>
using namespace std;
long long n, m, a[10100], b[10100];
long long f[10100], ans;
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i <= n; i++) scanf("%lld", &b[i]);
  for (long long i = 1; i <= n; i++) {
    f[i] = 1e15;
    for (long long j = i; j >= 1; j--)
      f[j] = std ::min(f[j - 1] + b[i], f[j] + a[i] + j * m);
    f[0] += a[i];
  }
  ans = 1e15;
  for (long long i = 0; i <= n; i++) ans = std ::min(ans, f[i]);
  printf("%lld", ans);
  return 0;
}
