import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Map<Long, PriorityQueue<Long>> beautyMap = new TreeMap<>(Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            long ti = sc.nextInt();
            long bi = sc.nextInt();
            if (!beautyMap.containsKey(bi))
                beautyMap.put(bi, new PriorityQueue<>(Collections.reverseOrder()));
            beautyMap.get(bi).add(ti);
        }
        long maxScore = 0;
        long maxDuration = 0;
        PriorityQueue<Long> priorityQueue = new PriorityQueue<>();

        for (Map.Entry<Long, PriorityQueue<Long>> kv : beautyMap.entrySet()) {
            PriorityQueue<Long> bMap = kv.getValue();

            while (bMap.size() > 0 && priorityQueue.size() < k) {
                long trackDuration = bMap.poll();
                priorityQueue.add(trackDuration);
                maxDuration += trackDuration;
            }

            while (bMap.size() > 0 && priorityQueue.peek() < bMap.peek()) {
                maxDuration -= priorityQueue.poll();
                long trackDuration = bMap.poll();
                maxDuration += trackDuration;
                priorityQueue.add(trackDuration);
            }

            maxScore = Math.max(maxDuration * kv.getKey(), maxScore);
        }
        System.out.println(maxScore);
    }
}