#include <bits/stdc++.h>
using namespace std;
typedef long long ll; // Note: long long is needed
const int N = 100100;
int a[N], b[N]; // Store a_i, b_i
int n, m;
bool check(ll mid) { // Check if the last skill upgrade can reach mid
ll cnt = 0;
for (int i = 0; i < n; ++i) {
if (a[i] < mid)
continue; // Initial value of skill i is less than mid, skip
cnt += (a[i] - mid) / b[i] + 1; // Number of times skill i is used
if (cnt >= m) // Total upgrades ≥ m, mid is too small
return true;
}
return false; // Total upgrades < m, mid is too large
}
int main() {
cin >> n >> m;
for (int i = 0; i < n; ++i)
cin >> a[i] >> b[i];
ll L = 1, R = 1000000; // Binary search for the highest possible last attack
while (L <= R) {
ll mid = (L + R) / 2;
if (check(mid)) L = mid + 1; // Increase mid
else R = mid - 1; // Decrease mid
}
ll attack = 0;
ll cnt = m;
for (int i = 0; i < n; ++i) {
if (a[i] < R) continue;
ll t = (a[i] - L) / b[i] + 1; // Number of upgrades for skill i
if (a[i] - b[i] * (t - 1) == R)
t -= 1; // If skill's upgrade equals R exactly, other skills are better
attack += (a[i] * 2 - (t - 1) * b[i]) * t / 2;
cnt -= t;
}
cout << attack + cnt * R << endl;
return 0;
}