#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define vc vector
#define st first
#define nd second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)a.size()
#define pub push_back
#define pob pop_back
ll INF = 1e18;
struct P {
ll h, c;
};
ll n, X;
vc<P> a;
void input() {
cin >> n >> X;
a.resize(n);
for (ll i = 0; i < n; i++)
cin >> a[i].h >> a[i].c;
}
void solve() {
if (n == 1) {
cout << "0\n";
return;
}
sort(all(a), [](auto &p, auto &q) {
if (p.h != q.h)
return p.h < q.h;
return p.c < q.c;
});
ll pre = 0;
for (ll i = 1; i < n; i++)
if (a[i].h == a[0].h) {
a[i].h++;
pre += X;
}
ll ans = INF;
for (ll k = 1; k < n; k++) {
ll x = 0;
x += (k - 1) * a[0].c;
multiset<ll> end;
for (ll i = 1; i < 1 + k; i++)
end.insert(a[i].h);
for (ll i = 1 + k; i < n; i++) {
ll f = *end.begin();
if (a[i].h <= f)
x += (f + 1 - a[i].h) * X;
else
f = a[i].h - 1;
end.erase(end.begin());
end.insert(f + 1);
}
ans = min(ans, x);
}
cout << pre + ans << "\n";
}
void program() {
input();
solve();
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
program();
return 0;
}