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

#PS0000247. Màu sơn được ưa chuộng nhất (AtColor)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Màu sơn được ưa chuộng nhất (AtColor)

AtColor

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

AtColor must choose an integer shade xx between 0 and 1000000 for its gray paint. Customer ii among nn surveyed customers will buy it exactly when ai≤x≤bia_i\le x\le b_i. Find the maximum possible number of buyers.

Input

First line: nn. Each of the next nn lines contains ai,bia_i,b_i.

Output

Print the maximum number of buyers, not the shade.

Subtasks

  • Subtask 1 (30 points): 1≤n≤20001\le n\le 2000; 0≤ai≤bi≤1060\le a_i\le b_i\le10^6.
  • Subtask 2 (70 points): 1≤n≤1000001\le n\le 100000; 0≤ai≤bi≤1060\le a_i\le b_i\le10^6.

Example 1

Input

4
0 2
2 3
2 4
5 6

Output

3

Explanation

Shade 2 belongs to the first three intervals; none belongs to all four.

Example 2

Input

4
1000000 1000000
1000000 1000000
0 1000000
1 1000000

Output

4

Explanation

All four customers accept shade 1000000.