Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. 

Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend to feel poor compared to somebody else in the company (Kefa doesn't count). A friend feels poor if in the company there is someone who has at least d units of money more than he does. Also, Kefa wants the total friendship factor of the members of the company to be maximum. Help him invite an optimal company!

Input

The first line of the input contains two space-separated integers, n and d (1 ≤ n ≤ 105, <image>) — the number of Kefa's friends and the minimum difference between the amount of money in order to feel poor, respectively.

Next n lines contain the descriptions of Kefa's friends, the (i + 1)-th line contains the description of the i-th friend of type mi, si (0 ≤ mi, si ≤ 109) — the amount of money and the friendship factor, respectively. 

Output

Print the maximum total friendship factir that can be reached.

Examples

Input

4 5
75 5
0 100
150 20
75 1


Output

100


Input

5 100
0 7
11 32
99 10
46 8
87 54


Output

111

Note

In the first sample test the most profitable strategy is to form a company from only the second friend. At all other variants the total degree of friendship will be worse.

In the second sample test we can take all the friends.
5 9
0 98
2 1000000000
8 1000000000
5 999999999
3 989898989
 4 1
2 4
2 2
3 3
3 3
 3 1
801 10101
802 134509124
801 1
 5 6
5 11
10 11
11 11
12 11
100 1
 7 6
5 11
9 11
10 11
11 11
12 11
13 11
100 1
 3 3
4 15
0 17
9 11
 15 1234
2738 322313356
1160 970909702
2594 902749351
3126 324754476
3151 177963947
3424 396145897
5578 737768323
3423 687640543
381 848813098
1058 197211286
936 650181776
1025 776492538
3598 142176544
3595 680519527
1191 32199940
 5 1
5 9
2 10
8 5
18 12
1 1
 8 5
3 227589091
12 131068951
8 492784630
20 918918112
11 6972428
20 585402296
12 220234661
1 225083234
 5 10
8 90
1009 1000000
9 121
10 298
0 109092
 4 2
1 1
2 100
3 100
4 1
 4 2
10909234 9
10909236 8
10909237 10
10909235 98
 1 1000000000
15 12

3989899086 6 134509124 33 55 17 3634263641 12 1504320408 1000000 200 107 12
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


/**
 * Pick questions that you love and solve them with love, try to get AC in one
 * go with cleanest code Just one thing to keep in mind these questions should
 * be out of your reach, which make you step out of comfort zone Try to pick
 * them from different topics CP is a sport, enjoy it. Don't make it pressure
 * cooker or job ****Use pen and paper************* check few examples analyze
 * them, some not given in sample also analyze then code Use pen and paper.
 * Solve on paper then code. If there is some reasoning e.g. sequence/paths, try
 * printing first 100 elements or 100 answers using brute and observe.
 * *********Read question with extreme caution. Mistake is happening here which
 * costs time, WA and easy problem not getting solved.********* Sometimes we
 * make question complex due to misunderstanding. Prefix sum and suffix sum is
 * highly usable concept, look for it. Think of cleanest approach. If too many
 * if else are coming then its indication of WA. Solve 1-2 more questions than
 * you solved during contest.
 */
public class Codeforces {

	private static final String NEWLINE = "\n";
	private static final String SPACE = " ";

	public static void main(String args[]) throws IOException {
//		FastReader in = new FastReader(); use in case of millions of strings
		Reader in = new Reader();
//		int t = in.nextInt();
//		while (t-->0) {
			int n = in.nextInt();
			long d = in.nextLong();
			Pair prs[] = new Pair[n];
			for (int i=0;i<n;i++) {
				prs[i] = new Pair(in.nextLong(), in.nextLong());
			}
			
			Arrays.parallelSort(prs, new Pair.PairComparatorX());
			long pref[] = new long[n];
			pref[0] = prs[0].y;
			for (int i=1;i<n;i++) pref[i] = pref[i-1] + prs[i].y;
			
			int l = 0;
			long max = 0;
			for (int i=0;i<n;i++) {
				int s = i;
				int e = bs(prs, n, s, d);
				if (s == 0) {
					if (pref[e]>max) max = pref[e];
					else if (pref[e]-pref[s-1]>max) max = pref[e]-pref[s-1];
				}
			}
			System.out.println(max);
//			while (l<n) {
//				int curr = l;
//				if (l+1<n && d>Math.abs(prs[l+1].x-prs[l].x)) {
//					long fs = prs[l].y;
//					long start = prs[l].x;
//					while (l+1<n && d>Math.abs(prs[l+1].x-start)) {
//						l++;
//						fs = fs + prs[l].y;
//					}
//					if (fs>max) max = fs;
//				} else {
//					if (prs[l].y>max) max = prs[l].y;
//				}
//				l = curr+1;
//			}
//			System.out.println(max);
//		}
		in.close();
	}
	
	private static int bs(Pair[] prs, int n, int s, long d) {
		long k = prs[s].x+d;
		if (s+1>=n) return s;
		if (prs[s+1].x >= k) return s;
		
		int l = s, r = n-1, ind = s;
		while (l<=r) {
			int mid = l + (r-l)/2;
			if (prs[mid].x<k) {
				ind = mid;
				l = mid+1;
			} else r = mid-1;
		}
		return ind;
	}

	static class Pair {
		Long x;
		Long y;

		private Pair(Long x, Long y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public boolean equals(Object o) {
			if (o == null || !(o instanceof Pair))
				return false;
			Pair cor = (Pair) o;
			return x.equals(cor.x) && y.equals(cor.y);
		}

		@Override
		public int hashCode() {
			int result = 17;
			return result;
		}

		static class PairComparatorX implements Comparator<Pair> {

			@Override
			public int compare(Pair o1, Pair o2) {
				return o1.x.compareTo(o2.x);
			}

		}

		static class PairComparatorY implements Comparator<Pair> {

			@Override
			public int compare(Pair o1, Pair o2) {
				return o1.y.compareTo(o2.y);
			}

		}

	}
	
	static class Reader {
		/**
		 * When reading millions of strings try using FastReader if getting tle
		 */
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;
		Scanner in = new Scanner(System.in);

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		String next() {
			return in.next();
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
			if (in == null) 
				return;
			in.close();
		}

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}