James loves drinking soup, specifically, magical soup. However, being the connoisseur of soup that he is, he is a picky drinker — meaning that his soup must be up to his standards. In particular, every time he drinks soup, it must satisfy the following conditions:
- The temperature of each bowl of soup must be no more than
when he drinks it, or his mouth will get burned. Each bowl of soup starts at some integer temperature and cools down by unit at the end of each minute. - Each bowl of soup must also be at most
minutes old when he drinks it. It isn't fresh enough for him after that.
James starts out with
Constraints
For all subtasks:
Subtask 1 [10%]
Subtask 2 [90%]
No additional constraints.
Input Specification
The first line will contain 2 integers
The following
Output Specification
Output one integer, the maximum number of bowls of soup James can drink.
Sample Input 1
1 3
3 2
5 1
2 3
Sample Output 1
2
Explanation for Sample Output 1
James can wait
Sample Input 2
20 5
100 91
30 10
69 10
20 1
1 2
Sample Output 2
4
Comments