#include <bits/stdc++.h>
using namespace std;
const int MAX = 4000005;
int n, r, aint[4 * MAX], lazy[4 * MAX];
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, const int &LeftUpdate,
            const int &RightUpdate, const int &add) {
  if (LeftUpdate <= left && right <= RightUpdate) {
    aint[node] += add;
    lazy[node] += add;
    return;
  }
  int mid = (left + right) / 2;
  if (LeftUpdate <= mid)
    Update(LeftSon(node), left, mid, LeftUpdate, RightUpdate, add);
  if (RightUpdate >= mid + 1)
    Update(RightSon(node), mid + 1, right, LeftUpdate, RightUpdate, add);
  aint[node] = max(aint[LeftSon(node)], aint[RightSon(node)]) + lazy[node];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> r;
  vector<pair<int, int> > points;
  for (int i = 1; i <= n; ++i) {
    int x, y, cx, cy;
    cin >> cx >> cy;
    x = cx + cy;
    y = cx - cy;
    points.push_back(make_pair(x, y));
  }
  sort((points).begin(), (points).end());
  int best = 0;
  for (int p = 0, q = 0; p < n; ++p) {
    int down, up;
    up = points[p].second + r + MAX / 2;
    down = points[p].second - r + MAX / 2;
    Update(1, 0, MAX, down, up, 1);
    while (points[p].first - points[q].first > 2 * r) {
      up = points[q].second + r + MAX / 2;
      down = points[q].second - r + MAX / 2;
      Update(1, 0, MAX, down, up, -1);
      ++q;
    }
    best = max(best, aint[1]);
  }
  cout << best << "\n";
  return 0;
}
