#000010

arhitekta

Inspired by the greatest world wonders of architecture, one architect gets the idea to make the tallest building constructed solely by using blocks. For that purpose, he collected lots of blocks from all over the world. All of the blocks have the same dimensions, but they are made of different materials, have different weights, and different carrying capacities. The architect knows the weight of every block and the maximum weight one could "put" on that block. Help him find the maximum number of blocks he could put one on top of the other without causing the structure to collapse.



InputThe first line of the standard input contains one integer B (1<=B<=5000) which represents the number of blocks. The next B lines contain two integers T and N separated by one space (1<==T, N<=32767). T represents the weight and N represents the carrying capacity of the block expressed in tons.


OutputIn the first and only line of the standard output write the number M. M is the largest number of blocks which can be stacked vertically, where the weight above every block is not larger than its carrying capacity.


Input:
4
10 5
20 10
10 20
8 12

Output:
3

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.