import java.io.*;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * Created by roi on 05.04.2016.
 */
public class Task1 {

    void solve(IO io) {
        int n = io.nextInt();
        int s = io.nextInt();

        long ans = 0;
        TreeMap<Item, Integer> is = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int count = io.nextInt();
            int power = io.nextInt();
            ans += count;
            Item key = new Item(count, power);
            is.put(key, is.getOrDefault(key, 0) + 1);
        }

        while (s > 0 && !is.isEmpty()) {
            Map.Entry<Item, Integer> e = is.pollFirstEntry();
            Item cur = e.getKey();
//            Item prev = cur.copy();
            int cnt = e.getValue();

            if (cnt > s) {
                cnt = s;
                s = 0;
            } else {
                s -= cnt;
            }
            ans -= cur.oneDefeats() * cnt;
            cur.count -= cur.oneDefeats();

            is.put(cur, is.getOrDefault(cur, 0) + cnt);
        }
        io.println(ans);
    }

    class Item implements Comparable<Item> {
        int count;
        int power;

        Item(int count, int power) {
            this.count = count;
            this.power = power;
        }

        int oneDefeats() {
            if (power >= count) return count;
            return power;
        }

        @Override
        public int compareTo(Item o) {
            int o1 = oneDefeats();
            int o2 = o.oneDefeats();
            if (o1 == o2) {
                if (count == o.count) {
                    return -Integer.compare(power, o.power);
                }
                return -Integer.compare(count, o.count);
            }
            return -Integer.compare(o1, o2);
        }

        Item copy() {
            return new Item(count, power);
        }
    }


    public static void main(String[] args) {
        Task1 solver = new Task1();
        IO io = new IO("castle");
        solver.solve(io);
        io.out.close();
    }

    static class IO {
        BufferedReader in;
        StringTokenizer tok;
        PrintWriter out;

        IO(String file) {
            try {
                in = new BufferedReader(new FileReader(file + ".in"));
                out = new PrintWriter(file + ".out");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String nextToken() {
            if (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
            return tok.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        int[] readIntArray(int len) {
            int[] res = new int[len];
            for (int i = 0; i < len; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        void println(long x) {
            out.println(x);
        }
    }

}
