Job!Job!Job!#3793

Job!Job!Job!

1.5 seconds
64 megabytes
Hard

Foreverlin is working in a company. In order to make boss happier, he must work as hard as possible, there are projects on the todolist. Now is time , after time , foreverlin has to go back to the school. Each project has two properties, the final completion time and the value you can make if you finish this project. At every unit of time, he can choose a project to finish. However, he can only choose one project to do in one unit of time, that means in one unit of time, he can choose a project to do and finish in this unit time. As his best friend, can you help him to find out how to arrange these projects so that he can maximize the total value.

Input

There are several test cases,in each test case, there are two numbers , (1 \le n \le 100000, 1 \le m \le 1000000). The next lines each contains two number D_i, V_i (1 \le D_i \le 100000, 1 \le V_i \le 10000) (1 \le i \le n, D_i means if you choose to do project , you can not do this after time D_i, V_i means the value of project ). The input will finish with the end of file.

Output

For each the case output a number means the biggest values.

Examples

Example 1

Loading
Loading