Boxes#4701

Boxes

1 second
122.486 megabytes
Medium

Vasya has numerous boxes scattered throughout his room, and his mom wants him to tidy up. Due to limited space, Vasya plans to stack all the boxes on top of each other.

However, this might not always be feasible. For instance, placing a heavy iron object on a cardboard box filled with Christmas decorations could lead to needing new decorations for the next holiday season.

Vasya has weighed each box and estimated the maximum weight each can support. Your task is to help him find the maximum number of boxes he can stack such that for every box, the total weight of the boxes above it does not exceed its maximum weight capacity.

Input

The first line of the input contains an integer (1 \leq n \leq 10^5) — the number of boxes in the room. Each of the following lines contains two integers w_i and c_i (1 \leq w_i \leq 10^5, 1 \leq c_i \leq 10^9), where w_i is the weight of the -th box, and c_i is the maximum weight it can support.

Output

Output a single integer — the solution to the problem.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading