Greedy Pie Eaters
Farmer John has cows, conveniently labeled , who occasionally enjoy a change of pace from eating grass. As a special treat, Farmer John has baked pies, labeled through . Each cow enjoys pies with labels in the range (inclusive), and no two cows enjoy the exact same range of pies. Additionally, each cow has a weight, , which is an integer ranging from to .
Farmer John can select a sequence of cows, , who will then take turns eating in that order. However, the cows don't know how to share! When it is cow 's turn, she will consume all the pies she enjoys — that is, all remaining pies within the interval . Farmer John wants to avoid the awkward situation where a cow's turn comes and there are no pies left for her to enjoy. Therefore, he needs you to compute the largest possible total weight of a sequence where each cow in the sequence eats at least one pie.
Input
The first line contains two integers, and . The next lines each describe a cow in terms of the integers , and .
Output
Print the maximum possible total weight of a valid sequence.
Examples
In this example, if cow eats first, then there will be nothing left for cow to eat. However, if cow eats first, cow will be satisfied by eating only the second pie.