PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000068. Hãy chọn tôi (Choose Me)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hãy chọn tôi (Choose Me)

Choose Me

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

A city has NN towns. Town ii contains AiA_i supporters of Aoki and BiB_i supporters of Takahashi. If Takahashi gives a speech there, all Ai+BiA_i+B_i residents vote for him; otherwise only the AiA_i residents vote for Aoki, and BiB_i abstain. Find the minimum number of towns where Takahashi must speak to get strictly more votes than Aoki.

Input

The first line contains NN. The next NN lines contain Ai,BiA_i,B_i.

Output

Print the minimum number of towns.

Subtasks

  • Subtask 1 (20 points): 1≤N≤241\le N\le 24; 1≤Ai,Bi≤1091\le A_i,B_i\le10^9 for every ii.
  • Subtask 2 (30 points): 1≤N≤20001\le N\le 2000; 1≤Ai,Bi≤1091\le A_i,B_i\le10^9 for every ii.
  • Subtask 3 (50 points): 1≤N≤2000001\le N\le 200000; 1≤Ai,Bi≤1091\le A_i,B_i\le10^9 for every ii.

Examples

Input

4
2 1
2 2
5 1
1 3

Output

1

Explanation

Initially Aoki has 1010 votes and Takahashi has 00. Speaking in town 33 moves 55 votes away from Aoki and adds 66 to Takahashi, giving 66 versus 55. One speech is sufficient.