Score : $300$ points
There are $10^{100}+1$ villages, labeled with numbers $0$, $1$, $\ldots$, $10^{100}$.
For every integer $i$ between $0$ and $10^{100}-1$ (inclusive), you can pay $1$ yen (the currency) in Village $i$ to get to Village $(i + 1)$.
There is no other way to travel between villages.
Taro has $K$ yen and is in Village $0$ now. He will try to get to a village labeled with as large a number as possible.
He has $N$ friends. The $i$-th friend, who is in Village $A_i$, will give Taro $B_i$ yen when he reaches Village $A_i$.
Find the number with which the last village he will reach is labeled.
Input is given from Standard Input in the following format:
$N$ $K$ $A_1$ $B_1$ $:$ $A_N$ $B_N$
Print the answer.
2 3 2 1 5 10
4
Takahashi will travel as follows:
Thus, we should print $4$.
5 1000000000 1 1000000000 2 1000000000 3 1000000000 4 1000000000 5 1000000000
6000000000
Note that the answer may not fit into a $32$-bit integer.
3 2 5 5 2 1 2 2
10
He may have multiple friends in the same village.