#include <bits/stdc++.h>
using namespace std;
const int NMAX = 4000010;
int n, r;
int aint[4 * NMAX], lazy[4 * NMAX];
inline int LeftSon(int x) { return 2 * x; }
inline int RightSon(int x) { return 2 * x + 1; }
void Update(int node, int left, int right, int LeftUpdate, int RightUpdate,
            int add) {
  if (left > RightUpdate || right < LeftUpdate) return;
  if (LeftUpdate <= left && right <= RightUpdate) {
    lazy[node] += add;
    aint[node] += add;
    return;
  }
  int mid = (left + right) / 2;
  Update(LeftSon(node), left, mid, LeftUpdate, RightUpdate, add);
  Update(RightSon(node), mid + 1, right, LeftUpdate, RightUpdate, add);
  aint[node] = max(aint[LeftSon(node)], aint[RightSon(node)]) + lazy[node];
}
vector<pair<int, int> > points;
int main() {
  cin >> n >> r;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    int cx, cy;
    cin >> x >> y;
    cx = x + y;
    cy = x - y;
    points.push_back(make_pair(cx, cy));
  }
  sort(points.begin(), points.end());
  int best = 0;
  for (int st = 0, dr = 0; dr < n; ++dr) {
    Update(1, 0, NMAX, points[dr].second - r + NMAX / 2,
           points[dr].second + r + NMAX / 2, 1);
    while (points[dr].first - points[st].first > 2 * r) {
      Update(1, 0, NMAX, points[st].second - r + NMAX / 2,
             points[st].second + r + NMAX / 2, -1);
      ++st;
    }
    best = max(best, aint[1]);
  }
  cout << best;
  return 0;
}
