#include <bits/stdc++.h>
using namespace std;
long long n, k, x, sz, i, j, cnt, sum, ans, a[1000010], c[1000010], b[1000010],
    le[1000010], re[1000010];
vector<long long> zh[1000010];
priority_queue<long long> q;
int main() {
  scanf("%lld%lld", &n, &k);
  for (i = 1; i <= n; i++) scanf("%lld%lld", &a[i], &b[i]);
  for (i = 1; i <= n; i++) zh[b[i]].push_back(a[i]);
  for (i = 1000000; i; i--) {
    for (j = 0; j < zh[i].size(); j++) {
      x = zh[i][j];
      if (sz < k)
        sz++, q.push(-x), sum += x;
      else {
        q.push(-x);
        sum += x;
        sum += q.top();
        q.pop();
      }
    }
    ans = max(ans, sum * i);
  }
  printf("%lld", ans);
}
