Paired Up (Gold)#11225

Paired Up (Gold)

1 second
128 megabytes
Very hard

There are a total of (1 \le n \le 10^5) cows on the number line. The location of the -th cow is given by x_i, and the weight of the -th cow is given by y_i.

At Farmer John's signal, some of the cows will form pairs such that

It's up to you to determine the range of possible sums of weights of the unpaired cows. Specifically,

Input

The first line contains , and (1 \le k \le 10^9).

In each of the following lines, the -th contains x_i (0 \le x_i \le 10^9) and y_i (1 \le y_i \le 10^4). It is guaranteed that 0 \le x_1 < x_2 < \ldots < x_n \le 10^9.

Output

Print out the minimum or maximum possible sum of weights of the unpaired cows.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading

Note

Example 1

In this example, cows and can pair up because they are at distance , which is at most k = 2. This pairing is maximal, because cows and are at distance , cows and are at distance , and cows and are at distance , all of which are more than k = 2. The sum of weights of unpaired cows is 2 + 2 + 2 = 6.

Example 2

Here, cows and can pair up because they are at distance 2 \le k = 2, and cows and can pair up because they are at distance 2 \le k = 2. This pairing is maximal because only cow remains. The weight of the only unpaired cow here is simply .

Example 3

The answer for this example is 693 + 992 + 785 = 2470.