Recently, an interesting balloon-popping game can be commonly found near the streets. The rule of this game is quite simple: some balloons are tied to cells of a lattice, and you are allowed to throw some darts to prick the balloons. The more balloons you pierce, the more incredible prize you will get.
Probably because too many people have got bored with this childish game, a new variation of the game has appeared. In this variation, you should prick the balloons by shooting an air rifle instead of throwing darts. You can make six shots in total, three horizontally and three vertically. If you shoot horizontally (vertically, resp.), all balloons in the row (column, resp.) are popped. In order to increase the difficulty, there is one restriction imposed on your shots: the distances between any two adjacent horizontal shots and any two adjacent vertical shots must all equal to a given number $r$. The problem is, what is the maximum number of balloons you can pop by making three horizontal and three vertical shots, under the aforementioned restriction.
输入描述:
The first line of input is two integers n, r
, the number of balloons and the distance between any two adjacent horizontal or vertical shots.
The remaining part of the input is n lines, specifying the positions of the balloons. Each of these lines contains two integers x, y
, denoting a balloon positioned at (x, y). Note that multiple balloons may lie in the same position.
输出描述:
Output the answer as a single integer in one line.
示例1
输入
复制
7 1
0 0
1 1
2 2
3 3
4 4
5 5
7 8