from __future__ import print_function
from sys import stdin
from collections import *
from operator import itemgetter
from heapq import *
import os, sys, atexit

if sys.version_info[0] < 3:
    range = xrange
    from cStringIO import StringIO as BytesIO

    sys.stdout = BytesIO()
else:
    from io import BytesIO

    sys.stdout = BytesIO()
    _write = sys.stdout.write
    sys.stdout.write = lambda s: _write(s.encode())
atexit.register(lambda: os.write(1, sys.stdout.getvalue()))

input = BytesIO(os.read(0, os.fstat(0).st_size)).readline


def arr_inp(n):
    if n == 1:
        return [int(x) for x in input().split()]
    elif n == 2:
        return [float(x) for x in stdin.readline().split()]
    else:
        return list(stdin.readline()[:-1])



n, k = arr_inp(1)
cur, ans, queue, dis = 0, 0, [], set()

heapify(queue)
for i in range(n):
    x, y = arr_inp(1)
    heappush(queue, [-x, y])
    dis.add(y)

tem, active = 0, defaultdict(lambda: [0, 0], {i: [0, 0] for i in dis})

for i in dis:
    while queue and cur < k:
        s = heappop(queue)
        if s[1] >= i:
            tem += (-s[0])
            cur += 1
            active[s[1]][0] += -s[0]
            active[s[1]][1] += 1

    ans = max(ans, tem * i)
    tem -= active[i][0]
    cur -= active[i][1]

print(ans)
