#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 10;
struct node {
  int x, y, yy, v;
} b[N];
bool operator<(node a, node b) {
  if (a.x == b.x) return a.v > b.v;
  return a.x < b.x;
}
void rotate(int &x, int &y) {
  int xx = x, yy = y;
  x = xx - yy;
  y = xx + yy;
}
int n, k, x, y, xx, yy;
int Y[N], cnt;
int ans;
int mx[4 * N], cov[4 * N];
void pushdown(int p, int l, int r) {
  if (cov[p]) {
    mx[p << 1] += cov[p];
    cov[p << 1] += cov[p];
    mx[p << 1 | 1] += cov[p];
    cov[p << 1 | 1] += cov[p];
    cov[p] = 0;
  }
}
void update(int p, int l, int r, int ql, int qr, int v) {
  if (ql <= l && r <= qr) {
    mx[p] += v;
    cov[p] += v;
    return;
  }
  pushdown(p, l, r);
  int mid = (l + r) / 2;
  if (ql <= mid) update(p << 1, l, mid, ql, qr, v);
  if (qr > mid) update(p << 1 | 1, mid + 1, r, ql, qr, v);
  mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
}
int ask(int p, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return mx[p];
  pushdown(p, l, r);
  int mid = (l + r) / 2, ans = 0;
  if (ql <= mid) ans = max(ans, ask(p << 1, l, mid, ql, qr));
  if (qr > mid) ans = max(ans, ask(p << 1 | 1, mid + 1, r, ql, qr));
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    xx = x - k;
    yy = y;
    rotate(xx, yy);
    b[2 * i - 1] = node{xx, yy, yy + 2 * k, 1};
    xx = x + k;
    yy = y;
    rotate(xx, yy);
    b[2 * i] = node{xx, yy - 2 * k, yy, -1};
    Y[++cnt] = yy - 2 * k;
    Y[++cnt] = yy;
  }
  sort(Y + 1, Y + cnt + 1);
  cnt = unique(Y + 1, Y + cnt + 1) - (Y + 1);
  for (int i = 1; i <= 2 * n; ++i) {
    b[i].y = lower_bound(Y + 1, Y + cnt + 1, b[i].y) - Y;
    b[i].yy = lower_bound(Y + 1, Y + cnt + 1, b[i].yy) - Y;
  }
  sort(b + 1, b + 2 * n + 1);
  for (int i = 1; i <= 2 * n; ++i) {
    update(1, 1, cnt, b[i].y, b[i].yy, b[i].v);
    ans = max(ans, ask(1, 1, cnt, 1, cnt));
  }
  printf("%d\n", ans);
  return 0;
}
