

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class A {
	public static StringTokenizer st;
	public static BufferedReader in;
	public static PrintWriter out;
	public static String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}
	public static int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	public static class Brick implements Comparable<Brick> {
		public final int i, k, a;
		
		public Brick(int i, int a, int k) {
			this.i = i;
			this.k = k;
			this.a = a;
		}

		@Override
		public int compareTo(Brick o) {
			return	Integer.compare(Math.min(k, a), Math.min(o.k, o.a)) != 0 ?
					Integer.compare(Math.min(k, a), Math.min(o.k, o.a)) :
					Integer.compare(i, o.i);
		}
		
	}
	public static void main(String[] args) throws IOException {
		boolean test = false;
		String fileName = "castle";
		if (test) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader(fileName + ".in"));
			out = new PrintWriter(fileName + ".out");
		}
		int n = nextInt();
		int s = nextInt();
		TreeSet<Brick> bricks = new TreeSet<>();
		long ans = 0;
		for (int i = 0; i < n; i++) {
			int a = nextInt();
			ans += a;
			bricks.add(new Brick(i, a, nextInt()));
		}
		while (s > 0) {
			Brick b = bricks.pollLast();
			if (b.a == 0) {
				break;
			}
			int ds = Math.min(s, b.a / b.k);
			if (ds == 0) {
				ds = 1;
			}
			int d = Math.min(ds * b.k, b.a);
			ans -= d;
			s -= ds;
			bricks.add(new Brick(b.i, b.a - d, b.k));
		}
		out.print(ans);
		in.close();
		out.close();
	}

}
