Grid#1908

Grid

2 seconds
64 megabytes
Easy

There is an infinite grid on the plane consisting of vertical and horizontal lines. The lines are given by the equations X = i \cdot K and Y = j \cdot K for any integers and . Also, a set of points is given. A point is said to lie on the grid if it lies on at least one of the lines that form the grid.

The grid may be moved parallel to the coordinate axes. Translating the grid by a vector (dx, dy) means that each line X = i \cdot K becomes X = i \cdot K + dx, and each line Y = j \cdot K becomes Y = j \cdot K + dy. Find the maximum possible number of points from the given set that can simultaneously lie on the grid after its translation by some vector.

Input

The first line contains two integers and . Each of the next lines contains two integers X_i, Y_i — the coordinates of the -th point (1 \leq N \leq 10^5, 2 \leq K \leq 10^9). The coordinates of all points are integers and do not exceed 10^9 by absolute value. No two points coincide.

Output

Output the maximum possible number of points from the given set that can simultaneously lie on the grid.

Examples

Example 1

Loading
Loading