#include <bits/stdc++.h>
using namespace std;
int n, c;
long long dp[2][10005], p[10005], s[10005], ans = 0, mn;
int main() {
  scanf("%d%d", &n, &c);
  for (int i = 1; i <= n; i++) scanf("%lld", &p[i]);
  for (int i = 1; i <= n; i++) scanf("%lld", &s[i]);
  for (int i = 1; i <= n; i++) {
    ans += min(s[i], p[i]);
    int x = i & 1, y = (i - 1) & 1;
    for (int j = 0; j <= i; j++) {
      dp[x][j] = (1LL << 60);
      if (p[i] > s[i]) {
        if (j != i)
          dp[x][j] = min(dp[x][j], dp[y][j] + p[i] - s[i] + (long long)j * c);
        if (j) dp[x][j] = min(dp[x][j], dp[y][j - 1]);
      } else {
        if (j != i) dp[x][j] = min(dp[x][j], dp[y][j] + (long long)j * c);
        if (j) dp[x][j] = min(dp[x][j], dp[y][j - 1] + s[i] - p[i]);
      }
    }
  }
  mn = dp[n & 1][0];
  for (int i = 1; i <= n; i++) mn = min(mn, dp[n & 1][i]);
  printf("%lld\n", mn + ans);
  return 0;
}
