#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 1e6 + 2;
struct Line {
  int y, xl, xr, v;
  Line() {}
  Line(int y, int xl, int xr, int v) : y(y), xl(xl), xr(xr), v(v) {}
  bool operator<(const Line &rhs) const { return y < rhs.y; }
};
vector<Line> lines;
int x[N], y[N];
struct Tree {
  int data[N << 4];
  int add[N << 4];
  int qL, qR, v;
  void init() {
    memset(data, 0, sizeof(data));
    memset(add, 0, sizeof(add));
  }
  void update(int o, int L, int R) {
    if (qL <= L && R <= qR) {
      data[o] += v;
      add[o] += v;
      return;
    }
    push_down(o, L, R);
    int M = (L + R) / 2, lc = o << 1, rc = lc | 1;
    if (qL <= M) update(lc, L, M);
    if (qR > M) update(rc, M + 1, R);
    data[o] = max(data[lc], data[rc]);
  }
  int query(int o, int L, int R) {
    if (qL <= L && R <= qR) return data[o];
    push_down(o, L, R);
    int M = (L + R) / 2, lc = o << 1, rc = lc | 1;
    int val = -1;
    if (qL <= M) val = max(val, query(lc, L, M));
    if (M < qR) val = max(val, query(rc, M + 1, R));
    return val;
  }
  void push_down(int o, int L, int R) {
    int M = (L + R) / 2, lc = o << 1, rc = lc | 1;
    if (add[o]) {
      data[lc] += add[o], data[rc] += add[o];
      add[lc] += add[o], add[rc] += add[o];
      add[o] = 0;
    }
  }
} tree;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  int Min = 1e9;
  for (int i = 1; i <= n; i++) {
    int u, v;
    cin >> u >> v;
    x[i] = u + v, y[i] = u - v;
    Min = min(Min, x[i]);
  }
  int add = max(-Min, 0) + 1;
  int len = -1;
  for (int i = 1; i <= n; i++) {
    x[i] += add;
    len = max(len, x[i]);
  }
  for (int i = 1; i <= n; i++) {
    lines.emplace_back(y[i] - m, max(1, x[i] - m), min(len, x[i] + m), 1);
    lines.emplace_back(y[i] + m + 1, max(1, x[i] - m), min(len, x[i] + m), -1);
  }
  sort(lines.begin(), lines.end());
  int ans = 0;
  for (int i = 0, j; i < lines.size(); i = j) {
    j = i;
    while (j < lines.size() && lines[i].y == lines[j].y) {
      tree.qL = lines[j].xl, tree.qR = lines[j].xr, tree.v = lines[j].v;
      tree.update(1, 1, len);
      j++;
    }
    ans = max(ans, tree.data[1]);
  }
  cout << ans << endl;
  return 0;
}
