Moving Logs

아직 제출이 없습니다시간 제한0.5초메모리 제한1024 MB

문제

There are nn logs placed in a rectangular warehouse. The logs do not intersect or overlap each other. The right wall of the warehouse is open, through which logs can be dragged out to the right. A log is only moved parallel in the positive xx-axis direction. A log can only be pulled out if there are no other logs in the space through which it will move. In Figure G.1, the movement space of log 3 is grayed out. Log 3 cannot be pulled out until logs 1 and 5 have been removed.

Multiple logs can be pulled out simultaneously if there are no other logs in the space through which they will move. Suppose that it takes 1 unit of time to pull out a log. Your task is to pull out all the logs of the warehouse as quickly as possible.

In Figure G.1, in order to pull out all five logs, you have to pull out the logs one by one in the order of 1-5-3- 2-4. Therefore, it takes 5 units of time to complete the task. Note that since the end point of log 1 is located in the movement space of log 5, it is not possible to pull out log 5 first.

Consider an example shown in Figure G.2. Logs 2 and 4 can be pulled out at the same time. After that, you can pull out logs 1 and 3 at the same time. Finally, you can pull out log 5. Therefore, it takes 3 units time.

Figure G.1Figure G.2

Given the locations of nn logs, write a program to find the minimum time required to pull out all the logs.

입력

Your program is to read from standard input. The input starts with a line containing an integer nn (1n20,0001 \le n \le 20,000), where nn is the number of logs. The logs are numbered from 11 to nn. In the following nn lines, the ii-th line contains four integers, x_1x\_1, y_1y\_1, x_2x\_2, and y_2y\_2, where (x_1,y_1)(x\_1, y\_1) and (x_2,y_2)(x\_2, y\_2) are the coordinates of both end points of the ii-th log and all the integers are between 11 and 10910^9. The length of a log is more than 00 and no two logs intersect each other at any point.

출력

Your program is to write to standard output. Print exactly one line. The line should contain an integer representing the minimum units of time to pull out all the logs.