Sikka, the coin

5

1 votes
Problem

Seeing the current growth in cryptocurrency Aman has got a thought to mine Bitcoins, but it requires huge compute capacity, so he went to the market to look for high-end processors. The shopkeeper presented his series of AMD and Intel processors, but Aman didn't understand a word about its specifications. In order to help Aman decide, the shopkeeper has compiled all the features of a processor into a single integer( in simple words this represents its compute capacity). Higher the integer value, better is the processor.

For every processor, you are given its cost and value, Help Aman to get the largest possible compute capacity within a cost of C

 

Input 

The first line contains two space separated integers N and C, the number of processors and the total cost limit.

The next n lines contain two space separated integers, ci and pi, the cost of ith processor and the capacity of the ith processor.

 

Constraints

1<=C<=4 x 104

1<=N<=2 x 103

1<=ci, pi<=2 x 103

 

Output

Print the largest overall value of processor that Aman can buy within cost C.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The processor with capacity 8 and 5 should be picked, summing up the value to the maximum of 13 (and cost 3 which is within the limit C)

Editor Image

?