300529: CF100J. Interval Coloring

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Interval Coloringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Aryo has got a lot of intervals for his 2418th birthday. He is really excited and decided to color all these intervals with some colors. He has a simple rule for himself. He calls a coloring nice if there exists no three intervals a, b and c such that the following conditions are satisfied simultaneously:

  • a, b and c are colored with the same color,
  • ,
  • ,
  • .

Moreover he found out that for every intervals i and j, there is at least one point in i which isn't in j.

Given some set of intervals. You have to find the minimum number k, such that Aryo can find a nice coloring with k colors.

Input

The first line contains a single integer n (1 ≤ n ≤ 103), number of intervals.

The following n lines contain a interval description each. Each interval is described by two numbers si, ei which are the start and end points of it ( - 105 < si, ei < 105, si ≤ ei). See samples for clarity. A square bracket stands for including of the corresponding endpoint, while a round bracket stands for excluding.

Output

Write a single integer k — the minimum number of colors needed for a nice coloring.

ExamplesInput
2
[1,2)
(3,4]
Output
1
Input
3
[1,3]
[2,6]
(5,7)
Output
2

Input

加入题单

上一题 下一题 算法标签: