프로그램 명: boi_trian
제한시간: 5 초

A triangulation of a polygon is a set of triangles with vertices at the vertices of a polygon. These triangles must not overlap and must cover the whole polygon.

We define a polygon cut as a straight line separating the polygon into two pieces. Given a triangulated convex polygon, where each triangle has some color, find the maximal number of cuts one can do so that no two points of the same color end up in two different pieces.

입력

The input always contains data about a proper triangulation of a polygon and all triangles are colored.

출력

The program should write one line to standard output, containing one integer - the maximal number of cuts.

입출력 예

입력

5
1 2 3 2
4 5 1 1
3 1 4 2

출력

1

입력

6
1 4 2 1
2 4 5 2
6 2 5 3
3 6 5 1

출력

0

Constraints

3 ≤ n ≤ 100,000.
출처: boi 2009 

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]