Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

2179.   Magic Sticks Again
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 1118   Accepted Runs: 396    Multiple test files



Give you some magic sticks. Each magic stick has two different numbers carved on it, one on each end. If one stick (a) has a1,a2 (a1 < a2), and another stick (b) has b1,b2 (b1 < b2), a2 ≤ b1, then the two sticks can be connected into a new stick, with a1,b2 carved on its two ends.

What is the minimum number of sticks after the connection?

Input

The first line is a integer N (N ≤ 20000) indicating the number of given sticks. Each of the following N lines contains two integers p and q (0 ≤ p < q ≤ 108), denoting the two number carved on a stick.

Output

Output the minimum number of sticks after the connection.

Sample Input

4
1 5
3 8
5 21
13 34

Sample Output

2



Source: TOJ 2006 Weekly Contest 1
Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.3.0
Maintance:G.D.Retop. Developer: SuperHacker, G.D.Retop