AT_abc410_e [ABC410E] Battles in a Row
Description
Takahashi is about to play a game where he fights $ N $ monsters in order. Initially, Takahashi's **health** is $ H $ and his **magic power** is $ M $ .
For the $ i $ -th monster he fights, he can choose one of the following actions:
- Fight without using magic. This can only be chosen when his health is at least $ A_i $ , and his health decreases by $ A_i $ and the monster is defeated.
- Fight using magic. This can only be chosen when his magic power is at least $ B_i $ , and his magic power decreases by $ B_i $ and the monster is defeated.
The game ends when all $ N $ monsters are defeated or when he cannot take any action. What is the maximum number of monsters he can defeat before the game ends?
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ H $ $ M $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $ \vdots $ $ A_N $ $ B_N $
Output Format
Output the answer.
Explanation/Hint
### Sample Explanation 1
By taking the following actions, Takahashi can defeat $ 3 $ monsters before the game ends.
- Initially, his health is $ 10 $ and his magic power is $ 14 $ .
- Fight the $ 1 $ st monster without using magic. His health decreases by $ 5 $ , becoming health $ 5 $ and magic power $ 14 $ .
- Fight the $ 2 $ nd monster without using magic. His health decreases by $ 5 $ , becoming health $ 0 $ and magic power $ 14 $ .
- Fight the $ 3 $ rd monster using magic. His magic power decreases by $ 9 $ , becoming health $ 0 $ and magic power $ 5 $ .
- For the $ 4 $ th monster, he cannot choose either action, so the game ends.
### Sample Explanation 2
He may be able to defeat all monsters.
### Constraints
- $ 1 \leq N \leq 3000 $
- $ 1 \leq H,M \leq 3000 $
- $ 1 \leq A_i,B_i \leq 3000 $
- All input values are integers.