import java.io.*;
import java.util.*;

public class a1 {
	String fileName = "castle";

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

		Pair(int _x, int _y) {
			x = _x;
			y = _y;
		}

		@Override
		public int compareTo(Pair o) {
			if (this.x == o.x) {
				return this.y - o.y;
			} else {
				return this.x - o.x;
			}
		}

	}

	public void solve() throws IOException {
		int n = nextInt();
		int s = nextInt();

		int a[] = new int[n];
		int k[] = new int[n];
		Pair q[] = new Pair[n];

		long sum = 0;

		int mods[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			k[i] = nextInt();
			
			q[i] = new Pair(k[i], a[i]);

			mods[i] = a[i] % k[i];

			sum += (a[i] + k[i] - 1) / k[i];
		}

		if (sum <= s) {
			out.println(0);
		} else {
			Arrays.sort(mods);

			Arrays.sort(q);

			int l = 0;
			int l1 = 0;

			long add = 0;

			while (l < n && mods[l] == 0) {
				l++;
			}

			while (sum > s && (l < n || l1 < n)) {
				if (l < n && ((l1 < n && mods[l] < q[l1].x) || (l1 >= n))) {
					sum--;
					add += mods[l];
					l++;
				} else {
					if (l1 < n) {
						long kw = Math.min(sum - s, q[l1].y / q[l1].x);
						sum -= kw;
						add += 1l * q[l1].x * kw;
						l1++;
					}
				}
			}

			out.println(add);
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader(fileName + ".in"));
			out = new PrintWriter(fileName + ".out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

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

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

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

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		new a1().run();
	}

}