#t360. 零件分组

零件分组

Parts Grouping

Problem Background

Special for beginners, ^_^

Problem Description

A factory produces a batch of rod-shaped parts, each with a certain length (LiL_i) and weight (WiW_i). For processing purposes, they must be divided into several groups so that within each group the parts can be arranged into a sequence whose lengths and weights are both non-decreasing (if i<ji<j, then Li≤Lj,  Wi≤WjL_i\le L_j,\;W_i\le W_j). What is the minimum number of groups?

Input Format

The first line is an integer N  (N≤1000)N\;(N\le 1000), the number of parts. The second line contains NN pairs of positive integers, each pair being the length and weight of a part; both length and weight do not exceed 1000010000.

Output Format

Exactly one line: the minimum number of groups.

Sample Input

5
8 4 3 8 2 3 9 7 3 5

Sample Output

2

Constraints

1s, 1024KiB for each test case.