410539: GYM104037 D Point

Memory Limit:0 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Pointtime limit per test1.0 smemory limit per test512 MBinputpoint.inoutputpoint.out

In a plane, you are given $$$n$$$ points $$$(x_i, y_i)$$$. In addition, you can add $$$k$$$ points freely.

After adding $$$k$$$ points, you need to choose some points from $$$n + k$$$ points and form a sequence, meet either $$$x_{i+1} - x_i = 1, y_{i+1} = y_i$$$ or $$$y_{i+1} - y_i = 1, x_{i+1} = x_i$$$. Print the maximum length of the sequence.

Input

Read from file "point.in"

First line contains two integers $$$n, k$$$ — the number of given points and the number of points that you can add freely.

Following $$$n$$$ lines, $$$i$$$th contains two integers $$$x_i, y_i$$$ — $$$i$$$th given point.

Output

Output to file "point.out"

Print one integer — the maximum length of the sequence.

ExamplesInput
8 2
3 1
3 2
3 3
3 6
1 2
2 2
5 5
5 3
Output
8
Input
4 100
10 10
15 25
20 20
30 30
Output
103
Note

$$$$$$1 \leq n \leq 500,0 \leq k \leq 100,1 \leq x_i, y_i \leq {10}^9$$$$$$

All the given points are pairwise different.

There are no other constraints on added points except the count.

Source/Category

加入题单

上一题 下一题 算法标签: