Watermelons#11828

Watermelons

1.5 seconds
512 megabytes
Hard

Kostya grows watermelons on a large plane—not figuratively, but literally: the watermelon patch is located on a coordinate plane, and each watermelon grows at a point with integer coordinates (x_i, y_i).

Recently, Kostya received alarming news: developers have appeared on the horizon, who decided to erect a fence without warning—supposedly for the construction of a shopping center. Soon, the watermelons will be bulldozed.

Tomorrow, Kostya will file a complaint and stop this outrage, but right now he wants to assess the risks: how many watermelons could end up on the boundary of this fence if it is placed in the worst possible way?

A fence is considered to be a rectangle with sides parallel to the coordinate axes. A watermelon will be destroyed if it lies exactly on the perimeter of the rectangle (that is, on the boundary, but not inside or outside).

Determine the maximum number of watermelons that can be on the perimeter of some rectangle.

Input

The first line contains a single integer (1 \le n \le 2000)—the number of watermelons.

The next lines contain two integers x_i, y_i (0 \le x_i, y_i \le 2000)—the coordinates of each watermelon.

Output

Output a single number—the maximum number of watermelons that can simultaneously be on the perimeter of some rectangle with sides parallel to the axes.

Examples

Example 1

Loading
Loading