#include <bits/stdc++.h>
using namespace std;
struct PT {
  int x, y;
  PT() {}
  PT(int _x, int _y) { x = _x, y = _y; }
  bool operator<(const PT& o) const {
    if (y == o.y) {
      return x < o.x;
    }
    return y < o.y;
  }
} ara[3 * 100010];
struct SEG {
  int mx, lz;
  SEG() {}
  SEG(int _mx, int _lz) { mx = _mx, lz = _lz; }
} tree[4 * 3 * 100010 + 10];
int n, rad;
vector<PT> xr, yr;
PT transfrm(PT p) {
  int d = p.y - p.x;
  p.x = 2 * p.x + d, p.y = d;
  return p;
}
void input() {
  int i, j;
  scanf("%d %d", &n, &rad);
  rad *= 2;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &ara[i].x, &ara[i].y);
    ara[i] = transfrm(ara[i]);
  }
}
bool cmp1(PT lhs, PT rhs) {
  if (lhs.x == rhs.x) {
    return lhs.y < rhs.y;
  }
  return lhs.x < rhs.x;
}
bool cmp2(PT lhs, PT rhs) {
  if (lhs.y == rhs.y) {
    return lhs.x < rhs.x;
  }
  return lhs.y < rhs.y;
}
void makeTree(int lo, int hi, int iter) {
  int mid = (lo + hi) >> 1;
  if (lo == hi) {
    tree[iter] = SEG(0, 0);
    return;
  } else if (lo < hi) {
    tree[iter] = SEG(0, 0);
    makeTree(lo, mid, 2 * iter + 1);
    makeTree(mid + 1, hi, 2 * iter + 2);
  }
}
void lazyUp(int iter, int v) {
  tree[iter].lz += v;
  tree[iter].mx += v;
}
void pushDown(int iter) {
  lazyUp(2 * iter + 1, tree[iter].lz);
  lazyUp(2 * iter + 2, tree[iter].lz);
  tree[iter].lz = 0;
}
void mrg(int iter) {
  tree[iter].mx = max(tree[2 * iter + 1].mx, tree[2 * iter + 2].mx);
}
void update(int lo, int hi, int iter, int l, int r, int v) {
  int mid = (lo + hi) >> 1;
  if (l <= lo && r >= hi) {
    lazyUp(iter, v);
    return;
  } else if (l > hi || r < lo) {
    return;
  } else {
    pushDown(iter);
    update(lo, mid, 2 * iter + 1, l, r, v);
    update(mid + 1, hi, 2 * iter + 2, l, r, v);
    mrg(iter);
  }
}
void solve() {
  int i, j, l, r, mx = 0;
  for (i = 0; i < n; i++) {
    xr.push_back(ara[i]), yr.push_back(ara[i]);
  }
  sort(xr.begin(), xr.end(), cmp1);
  sort(yr.begin(), yr.end(), cmp2);
  makeTree(0, n - 1, 0);
  for (i = 0, j = 0; i < xr.size(); i++) {
    for (; j < xr.size() && xr[j].x <= xr[i].x + rad; j++) {
      l = lower_bound(yr.begin(), yr.end(), PT(-INT_MAX, xr[j].y - rad), cmp2) -
          yr.begin();
      r = upper_bound(yr.begin(), yr.end(), PT(INT_MAX, xr[j].y), cmp2) -
          yr.begin();
      r--;
      update(0, n - 1, 0, l, r, 1);
    }
    mx = max(mx, tree[0].mx);
    l = lower_bound(yr.begin(), yr.end(), PT(-INT_MAX, xr[i].y - rad), cmp2) -
        yr.begin();
    r = upper_bound(yr.begin(), yr.end(), PT(INT_MAX, xr[i].y), cmp2) -
        yr.begin();
    r--;
    update(0, n - 1, 0, l, r, -1);
  }
  printf("%d", mx);
  puts("");
}
int main() {
  input();
  solve();
}
