#include <bits/stdc++.h>
using namespace std;
long long dp[2][11000];
int p[11000], s[11000];
int main() {
  int n, c;
  long long ans = 0;
  scanf("%d%d", &n, &c);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]), ans += s[i];
  int x = 0;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    x = x ^ 1;
    memset(dp[x], 0x20, sizeof(dp[x]));
    for (int j = 0; j < i; j++) {
      dp[x][j] = min(dp[x][j], dp[x ^ 1][j] + p[i] + (long long)j * c);
      dp[x][j + 1] = min(dp[x][j + 1], dp[x ^ 1][j] + s[i]);
      if (i == n) ans = min(min(ans, dp[x][j]), dp[x][j + 1]);
    }
  }
  cout << ans << '\n';
  return 0;
}
