#include <bits/stdc++.h>
using namespace std;
int seg[3 * 300007];
int lazy[3 * 300007];
void dos(int l, int r, int node) {
  seg[node] = seg[node] + lazy[node];
  if (l != r && lazy[node]) {
    lazy[node << 1ll] += lazy[node];
    lazy[(node << 1ll) + 1] += lazy[node];
  }
  lazy[node] = 0;
}
void update(int l, int r, int upl, int upr, int val, int node) {
  dos(l, r, node);
  if (l > upr || r < upl) return;
  if (l >= upl && r <= upr) {
    lazy[node] = val;
    dos(l, r, node);
    return;
  }
  int mid = (l + r) >> 1;
  update(l, mid, upl, upr, val, 2 * node);
  update(mid + 1, r, upl, upr, val, 2 * node + 1);
  seg[node] = max(seg[2 * node], seg[2 * node + 1]);
}
int query(int l, int r, int ql, int qr, int node) {
  dos(l, r, node);
  if (l > qr || r < ql) return 0;
  if (l >= ql && r <= qr) {
    return seg[node];
  }
  int mid = (l + r) >> 1ll;
  int x = query(l, mid, ql, qr, 2 * node);
  int y = query(mid + 1, r, ql, qr, 2 * node + 1);
  return max(x, y);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, r;
  cin >> n >> r;
  int cnt = 0;
  map<int, int> x;
  vector<pair<int, int>> ans;
  vector<int> mas;
  vector<pair<int, int>> get;
  vector<pair<int, pair<int, int>>> fin;
  int ze = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    ans.push_back(make_pair((x + y), (x - y)));
    mas.push_back((x - y));
  }
  sort(mas.begin(), mas.end());
  map<int, int> re;
  for (auto j : mas) {
    if (re[j] == 0) x[j] = cnt++;
    re[j] = 1;
    get.push_back(make_pair(j, cnt - 1));
  }
  for (auto j : ans)
    fin.push_back(make_pair(j.first, make_pair(j.second, x[j.second])));
  for (int i = 0; i < 3 * cnt + 4; i++) {
    seg[i] = 0;
    lazy[i] = 0;
  }
  sort(fin.begin(), fin.end());
  int pt = 0;
  int m = fin.size();
  int anso = 0;
  for (auto j : fin) {
    int f = j.first + 2 * r;
    int loc = 0;
    while (pt < m && fin[pt].first <= f) {
      int dif = fin[pt].second.first;
      int grp = fin[pt].second.second;
      auto grpd =
          lower_bound(get.begin(), get.end(), make_pair(dif - 2 * r, 0));
      int l = grpd->second;
      int right = grp;
      update(0, cnt - 1, l, right, 1, 1);
      pt++;
    }
    loc = query(0, cnt - 1, 0, cnt - 1, 1);
    anso = max(anso, loc);
    int right = j.second.second;
    int xd = j.second.first;
    auto grpd = lower_bound(get.begin(), get.end(), make_pair(xd - 2 * r, 0));
    int l = grpd->second;
    update(0, cnt - 1, l, right, -1, 1);
  }
  cout << anso << '\n';
}
