#B3678. Fusu's Mental Power

    ID: 11337 Type: Default 1000ms 256MiB

Fusu's Mental Power

Fusu's Mental Power

Fusu has an attribute called mental power in the game. Initially, his mental power is \(x_0\). In his inventory, he has \(n\) pendants. For the \(i\)-th pendant, it can be equipped only if his current mental power is at least \(a_i\). Once equipped, his mental power increases by \(b_i\>.

Fusu will try to equip the pendants sequentially in the order from 1 to \(n\). When trying to equip a pendant, if his current mental power is not less than \(a_i\), he equips the pendant (and his mental power increases by \(b_i\)); otherwise, he skips this pendant and will never consider it again.

Your task is to compute the total number of pendants that Fusu manages to equip.

inputFormat

The first line contains two integers \(x_0\) and \(n\) --- the initial mental power and the number of pendants.

Each of the next \(n\) lines contains two integers \(a_i\) and \(b_i\), describing the \(i\)-th pendant's requirement and the increase in mental power upon equipping.

outputFormat

Output a single integer --- the total number of pendants Fusu equips.

sample

10 3
5 3
15 5
13 2
2

</p>