Oliver manages a bank and wants to close for the day soon. A long queue has formed at the counter: people heard that the bank raised its interest rate by 42 percent (from 0.01 percent per year to 0.0142 percent per year) and they all want to deposit cash.
There are far more people than time. Only one counter is open and it serves one person per minute. Oliver is greedy, so he wants to pick a subset of the queue whose total deposited cash is as large as possible. That money then works for the bank overnight.
There is a catch. Some people have to be somewhere else and cannot wait until the bank closes, so if they are not served by a certain time they simply leave. Oliver also switched off the infrared door sensor so that nobody else can come in, because the hall is crowded already.
Compute the largest amount of cash Oliver can collect before the bank closes, serving at most one person per minute.
The first line contains the number of people in the queue N and the time in minutes until the bank closes T (1≤N≤10000, 1≤T≤47).
Each of the next N lines contains two integers ci and ti. Here ci is the amount of cash in Swedish crowns that person i carries, and ti is the time in minutes from now after which person i leaves if not served. Serving one person takes one minute, and person i must be started no later than minute ti. A service starts at an integer minute among 0, 1, up to T−1, and only one person is served at each of those minutes. The values satisfy 1≤ci≤100000 and 0≤ti<T.
Print one line with the largest amount of money that can be collected from the queue before the bank closes.