Space Exploration
The Space Research Department has been assigned the task of photographing (n) objects from space within a designated area. This area is a square with dimensions (50 50) kilometers. If divided into (1 1) kilometer squares, the objects of interest are located at the centers of some of these unit squares.
To facilitate this, a coordinate system is established with the (OX) axis running from west to east and the (OY) axis from south to north. Each unit square is assigned coordinates ranging from (1) to (50), as illustrated in the figure below.
A high-resolution camera mounted on a space satellite is used for capturing images. This camera can photograph square areas of the Earth's surface measuring (k k) kilometers. Initially, the camera is aimed at the southwest corner of the specified area, meaning that if a picture is taken, unit squares with coordinates (x) and (y) from (1) to (k) kilometers will be captured.
Using special engines, the satellite's orbit can be adjusted, allowing the shooting area to shift one kilometer to the west, east, or north in a single day. However, moving the shooting area south is not possible. Pictures can be taken between these movements, and the time taken to capture an image is negligible.
The management of the department wants to know: what is the minimum number of days required to photograph all the objects in the specified area?
Your task is to write a program that, given the arrangement of objects and the size of the picture (k), calculates the minimum time required to photograph all the objects in the specified area.
Input
The first line of the input file contains two integers: (n) and (k) ((1 n 1000), (1 k 5)).
The next (n) lines each contain two integers: (x_i) and (y_i) — the coordinates of the objects in the specified area ((1 x_i, y_i 50)).
Output
The output file should contain a single integer: the minimum number of days required to photograph all the objects in the specified area.
Explanation of examples
In the first example, the following sequence of actions is possible: take a picture, move (9) times to the east, move north, take a picture, move (9) times to the west, move north, take a picture, move (9) times to the east, move north, take a picture. A total of (30) movements of the shooting area are needed.
In the second example, the objects are located in the same place, but the picture size is larger, allowing the following actions: take a picture, move north, take a picture, move (8) times to the east, take a picture, move north, take a picture. Only (10) movements of the shooting area are needed.
In the third example, there is no need to move the shooting area; just take a picture.
The fourth example corresponds to the figure shown above.