#include <bits/stdc++.h>
using namespace std;
int id = 0;
const int maxn = 300010;
int p[maxn << 2], t[maxn << 2];
struct no {
  int x, y;
} a[maxn];
bool Cmp(no a, no b) { return a.x < b.x; }
void pushdown(int o) {
  int l = o << 1;
  int r = o << 1 | 1;
  p[l] += p[o];
  p[r] += p[o];
  t[l] += p[o];
  t[r] += p[o];
  p[o] = 0;
}
void add(int x, int y, int val, int o = 1, int l = 1, int r = id) {
  if (x <= l && r <= y) {
    t[o] += val;
    p[o] += val;
    return;
  }
  if (y < l || r < x) return;
  pushdown(o);
  int mid = (l + r) >> 1;
  add(x, y, val, o << 1, l, mid);
  add(x, y, val, o << 1 | 1, mid + 1, r);
  t[o] = max(t[o << 1], t[o << 1 | 1]);
}
int main() {
  int n, r;
  scanf("%d%d", &n, &r);
  r = r * 2;
  map<int, int> cmp;
  map<int, int>::iterator it;
  for (int i = 0; i < n; i++) {
    int X, Y;
    scanf("%d%d", &X, &Y);
    a[i].x = X + Y;
    a[i].y = X - Y;
    cmp[a[i].y];
    cmp[a[i].y + r];
  }
  sort(a, a + n, Cmp);
  for (it = cmp.begin(); it != cmp.end(); it++) {
    (*it).second = ++id;
  }
  int l = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    int q;
    while (l < i && (a[i].x - a[l].x) > r) {
      q = a[l].y;
      add(cmp[q], cmp[q + r], -1);
      ++l;
    }
    q = a[i].y;
    add(cmp[q], cmp[q + r], 1);
    ans = max(ans, t[1]);
  }
  printf("%d\n", ans);
}
