WINDOWS | 프로그래밍의 벗 PivotOJ
PivotOJ

WINDOWS

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2002 Regional Competition - SeniorsBOJ 3255

문제

In popular operating system we opened lots of windows.

Each window is rectangle consisting of small squares (of dimension 1 x 1).

Newly opened windows, depending of its position and size, can (partially or totally) cover some earlier opened windows.

We can close window with mouse if we click on its upper right small square, which in that moment must be visible. Square of some window is visible if there is no later opened window, which is not yet closed.

Write the program that will calculate the minimal number of mouse clicks to close the window that we opened first.

입력

In first line of input file there is integer N, number of windows, 1 ≤ N ≤ 100.

In each of the next N lines there are 4 integers R1, S1, R2 and S2, separated with spaces, 1 ≤ R1 ≤ R2 ≤ 10000, 1 ≤ S1 ≤ S2 ≤ 10000. Numbers R1 and S1 stand for row and column of the screen in which is upper-left square of that window, and R2 and S2 stand for row and column of the screen in which is lower-right square of that windows. Windows are opened in the same order like they appears in the input file.

We imagine screen as it consits of rows and columns of small squares. Rows are numerated from the top to the bottom, columns from the left to the right, and upper-left square on the screen is in the first row and first column. 

출력

In first and only line of output file you should write the minimal number of mouse clicks. 

예제

예제 1

입력
3
3 1 6 4
1 2 4 6
2 3 5 5
출력
3

예제 2

입력
3
4 1 6 3
2 2 5 5
1 4 3 6
출력
3

예제 3

입력
3
3 3 4 4
1 1 2 2
5 5 6 6
출력
1
코드를 제출하려면 로그인하세요.