import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni(), k = in.ni();
            int MAX = 1_000_000;
            long[] sums = new long[MAX + 3];
            List<Integer>[] g = new List[MAX + 3];
            PriorityQueue<Integer> pq = new PriorityQueue<>((o1, o2) -> -Integer.compare(o1, o2));
            for (int i = 0; i < n; i++) {
                int t = in.ni(), b = in.ni();
                if (g[b] == null)
                    g[b] = new LinkedList<>();
                sums[b] += t;
                g[b].add(t);
            }
            long best = 0;
            long sum = 0;
            for (int i = MAX; i >= 1; i--) {
                if (sums[i] == 0)
                    continue;
                for (Integer t : g[i]) {
                    if (pq.size() < k) {
                        pq.offer(t);
                        sum += t;
                    } else {
                        if (pq.peek() < t) {
                            sum -= pq.poll();
                            pq.offer(t);
                            sum += t;
                        }
                    }
                }
                best = Math.max(best, i * sum);
            }
            out.println(best);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}

