#include <bits/stdc++.h>
using i64 = long long;
using i128 = __int128_t;
#ifdef DEBUG
#include "/home/ahmetalp/Desktop/Workplace/debug.h"
#else
#define debug(...) void(23)
#endif
template<typename T>
bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
constexpr int max_N = 300 + 5;
constexpr i128 inf = __int128_t(1E36);
int N;
i64 K;
int H[max_N];
int C[max_N];
int M;
int cnt[2 * max_N];
int mn[2 * max_N];
bool vis[2 * max_N][max_N][max_N];
i128 dp[2 * max_N][max_N][max_N];
// std::pair<int, i64> h(int x, int y, int t1, int t2) {
// i64 res = 0;
// int t = t2 - t1;
// for (int i = 0; i < t && x; ++i) {
// int take = std::min(x, y);
// x -= take;
// res += take * (t1 + i);
// }
// return {x, res * K};
// }
std::pair<int, i128> g(int x, int y, int t1, int t2) {
if (x == 0) {
return {0, 0};
}
int t = t2 - t1;
int n = (x + y - 1) / y;
assert(n >= 1);
if (n <= t) {
int lst = x - (n - 1) * y;
__int128_t c = __int128_t(1) * y * t1 * (n - 1) + __int128_t(1) * y * (n - 1) * (n - 2) / 2 + __int128_t(1) * lst * (t1 + n - 1);
return {0, c * K};
} else {
__int128_t c = __int128_t(1) * y * t1 * t + __int128_t(1) * y * t * (t - 1) / 2;
return {x - y * t, c * K};
}
}
std::vector<int> all;
__int128_t f(int h, int a, int b) {
debug(h, a, b);
if (h == M) {
if (b != 0) {
return inf;
}
return 0;
}
if (vis[h][a][b]) {
return dp[h][a][b];
}
vis[h][a][b] = true;
__int128_t& res = dp[h][a][b] = inf;
chmin(res, f(h + 1, a, b + cnt[h]));
if (a == 0) {
if (mn[h]) {
auto[nb, c] = g(b + cnt[h], 1, all[h], all[h + 1]);
chmin(res, f(h + 1, 1, nb) + c);
}
} else {
if (a != N) {
chmin(res, f(h, a + 1, b) + C[mn[h - 1]]);
}
auto[nb, c] = g(b + cnt[h], a, all[h], all[h + 1]);
chmin(res, f(h + 1, a, nb) + c);
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> N >> K;
for (int i = 1; i <= N; ++i) {
std::cin >> H[i] >> C[i];
}
for (int i = 1; i <= N; ++i) {
all.emplace_back(H[i]);
all.emplace_back(H[i] + 1);
}
std::sort(all.begin(), all.end());
all.erase(std::unique(all.begin(), all.end()), all.end());
M = int(all.size());
all.emplace_back(all.back() + N + 5);
for (int i = 1; i <= N; ++i) {
int p = int(std::lower_bound(all.begin(), all.end(), H[i]) - all.begin());
cnt[p] += 1;
if (mn[p] == 0 || C[mn[p]] > C[i]) {
mn[p] = i;
}
}
for (int i = 1; i < M; ++i) {
if (mn[i] == 0 || C[mn[i]] > C[mn[i - 1]]) {
mn[i] = mn[i - 1];
}
}
__int128_t ans = f(0, 0, 0);
for (int i = 1; i <= N; ++i) {
ans -= __int128_t(1) * K * H[i];
}
std::cout << i64(ans) << '\n';
return 0;
}