LearnPy Hub
← Arena
AdvancedRating 1900

Most Courses Before Their Deadlines

Each course takes d days and must be finished by its deadline day. You take courses one at a time starting on day 1. Print the largest number of courses you can complete.

Input

n; then n lines 'duration deadline'.

Output

One integer.

Sample 1

Input
4
100 200
200 1300
1000 1250
2000 3200
Output
3

Sample 2

Input
1
1 2
Output
1
solution.py
Output appears here
Most Courses Before Their Deadlines · Python Arena problem · LearnPy Hub