AT_past202212_l 区間

Description

You are given $ N $ segments $ [L_1, R_1], [L_2, R_2], \ldots, [L_N, R_N] $ on a number line. A subset $ S $ of the set $ \lbrace 1, 2, \ldots, N \rbrace $ is said to be a **good set** if: - for all $ i, j \in S $ , at least one of the following two conditions is satisfied: - the segment $ [L_i, R_i] $ contains the segment $ [L_j, R_j] $ ; - the segment $ [L_j, R_j] $ contains the segment $ [L_i, R_i] $ . Here, a segment $ [L, R] $ is said to contain another segment $ [L', R'] $ if and only if $ L \leq L' $ and $ R' \leq R $ . Find the maximum possible size of a good set.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ L_1 $ $ R_1 $ $ L_2 $ $ R_2 $ $ \vdots $ $ L_N $ $ R_N $

Output Format

Print the answer.

Explanation/Hint

### Sample Explanation 1 The set $ \lbrace 2, 3, 4 \rbrace $ is a good set with the maximum size. Actually, - for $ 2, 3 \in S $ , $ [L_2, R_2] $ contains $ [L_3, R_3] $ ; - for $ 2, 4 \in S $ , $ [L_4, R_4] $ contains $ [L_2, R_2] $ ; and - for $ 3, 4 \in S $ , $ [L_4, R_4] $ contains $ [L_3, R_3] $ ; so the size $ 3 $ should be printed. ### Constraints - $ 1 \leq N \leq 2 \times 10^5 $ - $ 0 \leq L_i < R_i \leq 10^9 $ - All values in the input are integers.