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

#GD0000078. Các sinh vật cần điều hòa (Air Conditioned Minions)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Các sinh vật cần điều hòa (Air Conditioned Minions)

Air Conditioned Minions

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn minions. Minion ii tolerates any integer room temperature in the closed interval [li,ri][l_i,r_i]. All minions must be assigned to rooms, each of which has one common temperature suitable for every occupant. A room can hold any number of minions. Find the minimum number of rooms.

Input

The first line contains nn. Each of the next nn lines contains li,ril_i,r_i.

Output

Print the minimum number of rooms.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le 20; −109≤li≤ri≤109-10^9\le l_i\le r_i\le10^9.
  • Subtask 2 (30 points): 1≤n≤20001\le n\le 2000; −109≤li≤ri≤109-10^9\le l_i\le r_i\le10^9.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; −109≤li≤ri≤109-10^9\le l_i\le r_i\le10^9.

Examples

Input

4
18 22
20 24
23 28
26 30

Output

2

Explanation

Place the first two minions in a room at temperature 2020, and the last two at temperature 2626. One room cannot work because intervals [18,22][18,22] and [26,30][26,30] have no common temperature. The minimum is 22.