- Time limit: 1.00 s
- Memory limit: 512 MB
Uolevi is going to buy two portions of ice cream: one for Maija and one for himself. For each possible choice, you know its price and weight. You also know the maximum amount of money Uolevi can use.
Your task is to find out the maximum total weight of the ice cream. Note that Uolevi may also buy two similar portions.
Input
The first input line contains two integers n and x: the number of choices, and the money Uolevi has.
After this, the input contains n lines. Each line describes one choice and contains two integers h and p: the price and weight of the choice.
You can assume that there is at least one solution.
Output
You should print one integer: the maximum total weight.
Example 1
Input:
3 10 1 1 5 4 9 8
Output:
9
Explanation: Uolevi buys portions with prices 1 and 9.
Example 2
Input:
2 7 4 2 3 5
Output:
10
Explanation: Uolevi buys two portions with price 3.
Constraints
- 1 \le n \le 100
- 1 \le x,h,p \le 1000
Grading
You will get 100 points for the task if your program produces a correct answer for each test case, and otherwise you will get 0 points.