
Willson the Canada Goose is like any other Canada goose - he likes to eat grass. But, as anyone knows, there are different types of grass (e.g. green, blue, white, corn). Additionally, some humans like to feed geese with other foodstuffs (e.g. bread, pizza, hot dogs).
Each food type can provide energy to Willson or drain it away if it's unhealthy. Willson's energy can become negative. Willson must use up one unit of energy in order to move one meter. Willson cannot move if he has zero or negative energy, but he can still eat. You know the energy values of
Willson sees
How many food items can Willson eat?
Input Specification
The first line of input will contain
The next line of input will contain
All strings will be at most 10 characters long and will only contain lowercase English letters.
It is guaranteed that
Output Specification
Output a single integer, the number of food items that Willson can eat.
Sample Input
3
grass 5
bread 10
metal -100
5
bread 5
grass 0
grass 6
bread 10
metal 9
Sample Output
4
Explanation for Sample Output
Willson first eats the
Comments