#include <bits/stdc++.h>
const long long Inf = 1e18;
const long double eps = 1e-7;
long long LINF = (long long)2e18;
using namespace std;
long long mod = 1e9 + 7;
long long mod5 = 1e9 + 9;
long long mod3 = 998244353;
long long mod4 = 1000003;
long long mod2 = 1e9 + 123;
const int MAXN = 4000001;
const int INF = 1000000000;
int n, r;
vector<pair<int, int> > xy;
struct Tree {
  vector<long long> lazy;
  vector<long long> t;
  Tree(int n) {
    t.resize(4 * n);
    lazy.resize(4 * n, 0);
  }
  void push(int v, int tl, int tr) {
    t[v] += lazy[v];
    if (tl != tr) {
      lazy[2 * v] += lazy[v];
      lazy[2 * v + 1] += lazy[v];
    }
    lazy[v] = 0;
  }
  void update(int v, int tl, int tr, int l, int r, int x) {
    push(v, tl, tr);
    if (l == tl && r == tr) {
      lazy[v] += x;
      push(v, tl, tr);
      return;
    }
    int tm = (tl + tr) / 2;
    if (r <= tm) {
      update(2 * v, tl, tm, l, r, x);
      push(2 * v + 1, tm + 1, tr);
    } else if (l > tm) {
      update(2 * v + 1, tm + 1, tr, l, r, x);
      push(2 * v, tl, tm);
    } else {
      update(2 * v, tl, tm, l, tm, x);
      update(2 * v + 1, tm + 1, tr, tm + 1, r, x);
    }
    t[v] = max(t[2 * v], t[2 * v + 1]);
  }
  long long mx(int v, int tl, int tr, int l, int r) {
    push(v, tl, tr);
    if (l == tl && r == tr) {
      return t[v];
    }
    int tm = (tl + tr) / 2;
    if (r <= tm)
      return mx(2 * v, tl, tm, l, r);
    else if (l > tm)
      return mx(2 * v + 1, tm + 1, tr, l, r);
    else {
      return max(mx(2 * v, tl, tm, l, tm),
                 mx(2 * v + 1, tm + 1, tr, tm + 1, r));
    }
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  cin >> n >> r;
  xy.resize(n);
  int mn = 1e9;
  for (int(i) = 0; (i) < n; (i)++) {
    int x, y;
    cin >> x >> y;
    xy[i].first = x + y;
    xy[i].second = x - y;
    mn = min(mn, xy[i].second);
  }
  for (int(i) = 0; (i) < n; (i)++) {
    xy[i].second -= mn;
  }
  sort((xy).begin(), (xy).end());
  int itl = 0, itr = 0;
  r *= 2;
  long long ans = 0;
  Tree t(MAXN);
  while (itl != n) {
    if (itr < n && xy[itr].first - xy[itl].first <= r) {
      t.update(1, 0, MAXN - 1, max(0, xy[itr].second - r), xy[itr].second, 1);
      ans = max(ans, t.mx(1, 0, MAXN - 1, 0, MAXN - 1));
      itr++;
    } else {
      t.update(1, 0, MAXN - 1, max(0, xy[itl].second - r), xy[itl].second, -1);
      itl++;
    }
  }
  cout << ans;
  return 0;
}
