output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N D
      x_1 y_1
      :
      x_N y_N
attempt: n, d = map(int, input().split())
  
  m = [[0] * d for i in range(d)]
  for i in range(n):
      bnm, jkl = map(int, input().split())
      i = bnm % d
      j = jkl % d
      m[i][j] += 1
  
  
  for i in range(d):
      for j in range(d):
          if m[i][j] != 0:
              l = 1
              if i <= d - i:
                  p = i
              p = min(i, abs(d - i))
              q = min(j, abs(d - j))
  
              g = 10**5
              h = 0
              for qqq in range(100):
                  a = (g + h) // 2
                  c = ((a - p) // d + (a + p) // d + 1) * (
                      (a - q) // d + (a - q) // d + 1
                  )
                  if c > m[i][j]:
                      g = a
                  else:
                      h = a
              a = h
              if ((a - p) // d + (a + p) // d + 1) * (
                  (a - q) // d + (a - q) // d + 1
              ) >= m[i][j]:
                  m[i][j] = a
              else:
                  m[i][j] = g
  
  res = m[0][0]
  for i in range(d):
      for j in range(d):
          res = max(res, m[i][j])
  print(res)
  
problem_description: Statement
  
  Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he
  collected a lot of soft toys of her and spread them on the floor.
  
  Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread
  together with ordinary ones. He wanted these black rare soft toys to be close
  together, so he decided to rearrange them.
  
  In an infinitely large two-dimensional plane, every lattice point has a soft
  toy on it. The coordinates (x_i,y_i) of N black rare soft toys are given. All
  soft toys are considered to be points (without a length, area, or volume).
  
  He may perform the following operation arbitrarily many times:
  
    * Put an axis-aligned square with side length D, rotate the square by 90 degrees with four soft toys on the four corners of the square. More specifically, if the left bottom corner's coordinate is (x, y), rotate four points (x,y) \rightarrow (x+D,y) \rightarrow (x+D,y+D) \rightarrow (x,y+D) \rightarrow (x,y) in this order. Each of the four corners of the square must be on a lattice point.
  
  Let's define the _scatteredness_ of an arrangement by the minimum side length
  of an axis-aligned square enclosing all black rare soft toys. Black rare soft
  toys on the edges or the vertices of a square are considered to be enclosed by
  the square.
  
  Find the minimum scatteredness after he performs arbitrarily many operations.
samples: [{"input": "3 1\n    0 0\n    1 0\n    2 0", "output": "1\n    \n\n* * *"}, {"input": "19 2\n    1 3\n    2 3\n    0 1\n    1 1\n    2 1\n    3 1\n    4 4\n    5 4\n    6 4\n    7 4\n    8 4\n    8 3\n    8 2\n    8 1\n    8 0\n    7 0\n    6 0\n    5 0\n    4 0", "output": "4\n    \n\n* * *"}, {"input": "8 3\n    0 0\n    0 3\n    3 0\n    3 3\n    2 2\n    2 5\n    5 2\n    5 5", "output": "4"}]