Drawing Windows

No attempts yetTime limit1sMemory limit128 MB

Problem

Andrew is porting a text-mode windowed mailer to a new operating system. Like the classic Norton-style shells, the mailer draws its interface by writing characters into a screen buffer.

On this new system, however, every call that touches the screen buffer is painfully slow: writing a single character costs 1/60001/6000 of a second or more, so redrawing a window one character at a time is unbearable.

To speed things up, Andrew wants to use a system call that fills an entire axis-aligned rectangle of characters in one operation. Redrawing a window then means covering its visible region with as few non-overlapping rectangles as possible.

You are given the visible part of one window as a rectilinear region. Compute the minimum number of non-overlapping axis-aligned rectangles whose union is exactly that region.

Input

The visible region is described by its boundary, which consists only of horizontal and vertical segments with integer coordinates. The region has no holes, and its boundary neither touches nor intersects itself. Every segment is at least one character long.

The first line contains the number nn of vertices on the boundary. Each of the next nn lines gives the coordinates of one vertex in counter-clockwise order (on the screen the yy axis points downward). Horizontal and vertical segments alternate, and the last segment joins the last vertex back to the first.

n400n \le 400, and every coordinate has absolute value at most 200200.

Output

Output a single integer mm — the minimum number of non-overlapping axis-aligned rectangles needed to partition the visible region exactly (their union is the region and no two of them overlap).