Maximum Number of Noncrossing Circle Chords

Time limit1sMemory limit128 MB

Problem

There are 100 equally spaced points on the circumference of a circle, numbered 1 through 100 clockwise. You are given N line segments (chords) whose endpoints are among these points. Find the maximum number of given chords that can be chosen so that no two chosen chords intersect.

Here, 1 ≤ N ≤ 50, and each point appears as an endpoint of at most one chord.

Input

The first line contains the number of chords N. Each of the next N lines contains the two endpoint numbers of one chord.

Output

Print the maximum number of chords that can be chosen with no intersections between any two of them.

Hint

There is no additional hint.