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
//package cf_321;

import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * Created by Admin on 10/29/15.
 */
public class B
{
    public static class friend implements Comparable
    {
        int m;
        int s;

        @Override
        public int compareTo(Object o)
        {
            friend x = (friend) o;
            if (this.m>x.m) return 1;
            if (this.m<x.m) return -1;
            return 0;
        }
    }

    public static void main(String[] Args)
    {
        FasterScanner sc = new FasterScanner();
        int n = sc.nextInt();
        int d = sc.nextInt();
        friend [] f = new friend[n];
        for (int i =0; i<n; i++)
        {
            f[i]= new friend();
            f[i].m=sc.nextInt();
            f[i].s=sc.nextInt();
        }
        Arrays.sort(f);
        int i=0, j=1, a=0, b=0;
        long loyal = f[0].s, temp = f[0].s;
        while (j<n)
        {
            if (f[j].m-f[i].m<d)
            {
                temp+=f[j].s;
                j++;
            }
            else
            {
                if (temp>loyal)
                    loyal=temp;
                temp-=f[i].s;
                i++;
            }
        }

        if (temp>loyal)
            loyal=temp;
        System.out.print(loyal);
    }

    public static class FasterScanner
    {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = System.in.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n)
        {
            return nextIntArray(n, 0);
        }

        public int[] nextIntArray(int n, int off)
        {
            int[] arr = new int[n + off];
            for (int i = 0; i < n; i++)
            {
                arr[i + off] = nextInt();
            }
            return arr;
        }

        public long[] nextLongArray(int n)
        {
            return nextLongArray(n, 0);
        }

        public long[] nextLongArray(int n, int off)
        {
            long[] arr = new long[n + off];
            for (int i = 0; i < n; i++)
            {
                arr[i + off] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c)
        {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}
