#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
int sz = 4000000;
vector<int> addv, maxi;
int ul, ur, uv;
void update(int o, int l, int r) {
  if (ul <= l && ur >= r) {
    maxi[o] += uv;
    addv[o] += uv;
  } else {
    int m = (l + r) / 2;
    if (ul <= m) update(o * 2, l, m);
    if (ur > m) update(o * 2 + 1, m + 1, r);
    maxi[o] = max(maxi[o * 2], maxi[o * 2 + 1]) + addv[o];
  }
}
int main() {
  int n, r;
  cin >> n >> r;
  r <<= 1;
  vector<int> x(n, 0), y(n, 0);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (int i = 0; i < n; i++) {
    int tx = x[i] + y[i];
    int ty = x[i] - y[i];
    x[i] = tx + sz / 2;
    y[i] = ty + sz / 2;
  }
  vector<pair<pair<int, int>, int> > e;
  for (int i = 0; i < n; i++) {
    e.push_back(pair<pair<int, int>, int>(pair<int, int>(x[i], 1), i));
    e.push_back(pair<pair<int, int>, int>(pair<int, int>(x[i] + r + 1, 0), i));
  }
  sort(e.begin(), e.end());
  addv.assign(4 * sz + 10, 0);
  maxi = addv;
  int ans = 0;
  for (int i = 0; i < (int)e.size(); i++) {
    int t = e[i].second;
    if (e[i].first.second == 0) {
      ul = y[t];
      ur = y[t] + r;
      uv = -1;
      update(1, 0, sz);
    } else {
      ul = y[t];
      ur = y[t] + r;
      uv = 1;
      update(1, 0, sz);
      ans = max(ans, maxi[1]);
    }
  }
  cout << ans << endl;
  return 0;
}
