Valera loves his garden, where n fruit trees grow.

This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get withered, so they can only be collected on day ai and day ai + 1 (all fruits that are not collected in these two days, become unfit to eat).

Valera is not very fast, but there are some positive points. Valera is ready to work every day. In one day, Valera can collect no more than v fruits. The fruits may be either from the same tree, or from different ones. What is the maximum amount of fruit Valera can collect for all time, if he operates optimally well?

Input

The first line contains two space-separated integers n and v (1 ≤ n, v ≤ 3000) — the number of fruit trees in the garden and the number of fruits that Valera can collect in a day. 

Next n lines contain the description of trees in the garden. The i-th line contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ 3000) — the day the fruits ripen on the i-th tree and the number of fruits on the i-th tree.

Output

Print a single integer — the maximum number of fruit that Valera can collect. 

Examples

Input

2 3
1 5
2 3


Output

8


Input

5 10
3 20
2 20
1 20
4 20
5 20


Output

60

Note

In the first sample, in order to obtain the optimal answer, you should act as follows. 

  * On the first day collect 3 fruits from the 1-st tree. 
  * On the second day collect 1 fruit from the 2-nd tree and 2 fruits from the 1-st tree. 
  * On the third day collect the remaining fruits from the 2-nd tree. 



In the second sample, you can only collect 60 fruits, the remaining fruit will simply wither.
import java.io.*;
import java.math.*;
import java.util.*;


/**
 *
 * @author Saju
 *
 */

public class Main {

	private static int dx[] = { 1, 0, -1, 0 };
	private static int dy[] = { 0, -1, 0, 1 };

	private static final long INF = Long.MAX_VALUE;
	private static final int INT_INF = Integer.MAX_VALUE;
	private static final long NEG_INF = Long.MIN_VALUE;
	private static final int NEG_INT_INF = Integer.MIN_VALUE;
	private static final double EPSILON = 1e-10;

	private static final int MAX = 3007;
	
	private static final long MOD = 1000000007;

	private static final int MAXN = 10000007;
	private static final int MAXA = 10000009;
	private static final int MAXLOG = 22;

	public static void main(String[] args) throws IOException {

		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

//		 InputReader in = new InputReader(new FileInputStream("src/test.in"));
//		 PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("src/test.out")));



/*



*/
	
		int n = in.nextInt();
		int v = in.nextInt();
		List<Pair> pairs = new ArrayList<>();
	
		int arr[] = new int[MAX];
		for(int i = 0; i < n; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			arr[a] += b;
		}
		
		for(int i = 0; i < MAX; i++) {
			if(arr[i] > 0) {
				pairs.add(new Pair(i, arr[i]));
			}
		}
		
		
		Collections.sort(pairs, new Comparator<Pair>() {

			@Override
			public int compare(Pair o1, Pair o2) {
				int val = o1.day - o2.day;
				if(val == 0) {
					return o2.amount - o1.amount;
				}
				return val;
			}
		});
		
//		for(Pair p : pairs) {
//			System.out.println(p.day + " " + p.amount);
//		}
		
		long sum = 0;
		int prev = 0;
		
		if(pairs.get(0).amount >= v) {
			sum = v;
			prev = pairs.get(0).amount - v;
		}
		else {
			sum = pairs.get(0).amount;
		}
		
//		System.out.println(sum + " " + prev);
		for(int i = 1; i < pairs.size(); i++) {
			if(pairs.get(i).day == pairs.get(i - 1).day + 1) {
				if(prev + pairs.get(i).amount >= v) {
					if(prev >= v) {
						sum += v;
						prev = pairs.get(i).amount;
					}
					else {
						sum += prev;
						int add = v - prev;
						if(pairs.get(i).amount >= add) {
							sum += add;
							prev = pairs.get(i).amount - add;
						}
						else {
							sum += pairs.get(i).amount;
							prev = 0;
						}
					}
					
				}
				else {
					sum += prev + pairs.get(i).amount;
					prev = 0;
				}
			}
			else {
				sum += min(prev, v);
				if(pairs.get(i).amount >= v) {
					sum += v;
					prev = pairs.get(i).amount - v;
				}
				else {
					sum += pairs.get(i).amount;
					prev = 0;
				}
			}
//			System.out.println(sum + " " + prev);
		}
		
		if(prev > 0) {
			if(prev >= v) {
				sum += v;
			}
			else {
				sum += prev;
			}
		}
		
		out.println(sum);
		
		out.flush();
		out.close();
		System.exit(0);
	}
	
	private static class Pair{
		int day;
		int amount;
		
		Pair(int day, int amount){
			this.day = day;
			this.amount = amount;
		}
	}
	
	
	private static int ceil(int n, int x) {
		int div = n / x;
		if(div * x != n) {
			div++;
		}
		return div;
	}

	private static class Point {
		double x;
		double y;

		Point(double x, double y) {
			this.x = x;
			this.y = y;
		}

		double getDistance(Point p2) {
			Point p1 = this;
			double dx = p1.x - p2.x;
			double dy = p1.y - p2.y;

			return Math.sqrt((dx * dx) + (dy * dy));
		}
	}

	private static int abs(int x) {
		if (x < 0) {
			return -x;
		}
		return x;
	}

	private static long abs(long x) {
		if(x < 0) {
			return -x;
		}
		return x;
	}

	private static int lcm(int a, int b) {
		return (a * b) / gcd(a, b);
	}

	private static int gcd(int a, int b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	private static int log(long x, int base) {
		return (int) (Math.log(x) / Math.log(base));
	}

	private static long min(long a, long b) {
		if (a < b) {
			return a;
		}
		return b;
	}

	private static int min(int a, int b) {
		if (a < b) {
			return a;
		}
		return b;
	}

	private static long max(long a, long b) {
		if (a < b) {
			return b;
		}
		return a;
	}

	private static int max(int a, int b) {
		if (a < b) {
			return b;
		}
		return a;
	}

	private static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public String next() {
			try {
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					tokenizer = new StringTokenizer(reader.readLine());

				}
			} catch (IOException e) {
				return null;
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			String line = null;
			try {
				tokenizer = null;
				line = reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			return line;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public boolean hasNext() {
			try {
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					tokenizer = new StringTokenizer(reader.readLine());
				}
			} catch (Exception e) {
				return false;
			}
			return true;
		}
	}
}
	  						 	 	     			 	  	 			