#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
struct node {
  int beau, len;
  int num;
} cs[maxn];
bool cmp(node a, node b) {
  if (a.beau == b.beau) return a.len > b.len;
  return a.beau > b.beau;
}
long long sum[maxn];
priority_queue<int, vector<int>, greater<int> > que;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &cs[i].len, &cs[i].beau);
    cs[i].num = i;
  }
  sort(cs + 1, cs + n + 1, cmp);
  long long ans = 0, sum = 0;
  for (int i = 1; i <= n; i++) {
    int ed = i;
    while (cs[ed + 1].beau == cs[i].beau) ed++;
    for (int j = i; j <= ed; j++) {
      if (que.size() < k) {
        sum = sum + cs[j].len;
        que.push(cs[j].len);
      } else {
        if (que.top() < cs[j].len) {
          sum = sum - que.top() + cs[j].len;
          que.pop();
          que.push(cs[j].len);
        }
      }
    }
    ans = max(ans, sum * cs[i].beau);
    i = ed;
  }
  cout << ans << endl;
  return 0;
}
