Statement
Statement language
Bitaro, a warrior of the Lemon Kingdom, wants to increase his level by challenging dungeons.
There are dungeons. The difficulty of dungeon is represented by two integers and . If Bitaro challenges dungeon at level , the result is as follows.
- If , he fails and his level does not change.
- If , he succeeds and his level increases by .
Each dungeon can be challenged at most once. Bitaro may choose the order of the dungeons and may stop at any time.
Bitaro's current level is . Find the maximum level he can reach after challenging dungeons.
Input
The input is given from Standard Input in the following format:
Output
Print the maximum level Bitaro can reach.
Constraints
- .
- .
Subtasks
Samples
Sample 1
Input
3 5
0 100
4 6
5 7
Output
34
By challenging dungeons , , and in this order, Bitaro's level becomes , , and , respectively.