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

public class SolveA {
	String fileName = "castle";

	class Wall implements Comparable<Wall> {
		long k;
		long left;
		long canStand;
		int id;

		public Wall(long k, long left, long canStand, int id) {
			super();
			this.k = k;
			this.left = left;
			this.canStand = canStand;
			this.id = id;
		}

		@Override
		public int compareTo(Wall that) {
			if (this.canStand == that.canStand) {
				return this.id - that.id;
			}
			return Long.compare(that.canStand, this.canStand);
		}

		@Override
		public String toString() {
			return "Wall [k=" + k + ", left=" + left + ", canStand=" + canStand + ", id=" + id + "]";
		}
		
	}

	public void solve() throws IOException {
		// change to long!
		int n = nextInt();
		int s = nextInt();
		boolean flag = true;
		long[] a = new long[n];
		long[] k = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = nextInt();
			k[i] = nextInt();
			if (k[i] != 1) {
				flag = false;
			}
		}
		if (flag) {
			for (int i = 0; i < n; i++) {
				s -= a[i];
			}
			out.println(Math.max(-s, 0));
		}
		TreeSet<Wall> set = new TreeSet<Wall>();
		for (int i = 0; i < n; i++) {
			set.add(new Wall(k[i], a[i], k[i], i));
		}
		while (!set.isEmpty()) {
			//System.out.println(set + " " + set.size());
			if (s == 0) {
				break;
			}
			Wall f = set.first();
			set.remove(f);
			if (f.canStand < f.k) {
				f.left = 0;
				s--;
			} else if (s >= f.left / f.k) {
				s -= f.left / f.k;
				f.left = f.left % f.k;
				f.canStand = f.left;

			} else {
				f.left -= s * f.k;
				s = 0;
				break;
			}
			if (f.left > 0) {
				set.add(f);
				//System.out.println("added" + f);
			} else {
				//System.out.println("!!!" + f);
			}
		}
		long ans = 0;
		for (Wall x : set) {
			ans += x.left;
			//System.out.println(x.left);
		}
		out.println(ans);
	}

	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 SolveA().run();
	}

}