#include <bits/stdc++.h>
using namespace std;
const int delta = 2e6 + 10;
const int N = 4e6 + 20;
int n, r;
struct Event {
  int x, lo, hi, ok;
  Event(int _x = 0, int _lo = 0, int _hi = 0, int _ok = 0)
      : x(_x), lo(_lo), hi(_hi), ok(_ok) {}
  bool operator<(const Event &op) const {
    return x == op.x ? ok > op.ok : x < op.x;
  }
};
vector<Event> ev;
struct Tree {
  int L[N << 2], R[N << 2];
  int Max[N << 2], lazy[N << 2];
  void build(int i, int j, int id) {
    L[id] = i;
    R[id] = j;
    if (i == j) return;
    int mid = (i + j) / 2;
    build(i, mid, id * 2);
    build(mid + 1, j, id * 2 + 1);
  }
  void upd(int id, int d) {
    Max[id] += d;
    lazy[id] += d;
  }
  void down(int id) {
    if (lazy[id] && L[id] != R[id]) {
      upd(id * 2, lazy[id]);
      upd(id * 2 + 1, lazy[id]);
      lazy[id] = 0;
    }
  }
  void update(int id, int u, int v, int d) {
    if (L[id] > v || R[id] < u) return;
    if (u <= L[id] && R[id] <= v) {
      upd(id, d);
      return;
    }
    down(id);
    update(id * 2, u, v, d);
    update(id * 2 + 1, u, v, d);
    Max[id] = max(Max[id * 2], Max[id * 2 + 1]);
  }
} it;
int main() {
  if (fopen("abc"
            ".inp",
            "r")) {
    freopen(
        "abc"
        ".inp",
        "r", stdin);
    freopen(
        "abc"
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> r;
  r = r * 2;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    int _x = x - y;
    int _y = x + y;
    _x += delta;
    _y += delta;
    ev.push_back(Event(_x, _y, _y + r, 1));
    ev.push_back(Event(_x + r, _y, _y + r, -1));
  }
  it.build(1, N, 1);
  sort(ev.begin(), ev.end());
  int ans = 0;
  for (auto i : ev) {
    it.update(1, i.lo, i.hi, i.ok);
    ans = max(ans, it.Max[1]);
  }
  cout << ans;
  return 0;
}
