#include <bits/stdc++.h>
using namespace std;
const int dt = 2000010;
inline int read() {
  int x = 0, f = 0, c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return f ? -x : x;
}
int tree[16 * dt], lazy[16 * dt];
struct Point {
  int x, y, c;
  Point(int xx = 0, int yy = 0, int cc = 0) : x(xx), y(yy), c(cc) {}
};
bool operator<(const Point &a, const Point &b) {
  if (a.y != b.y) return a.y < b.y;
  if (a.x != b.x) return a.x < b.x;
  return a.c < b.c;
}
vector<Point> p;
inline void tran(int &x, int &y) {
  int xx = x, yy = y;
  x = xx - yy + dt;
  y = xx + yy + dt;
}
inline void pushup(int x) { tree[x] = max(tree[x << 1], tree[x << 1 | 1]); }
inline void pushdown(int x) {
  if (lazy[x]) {
    lazy[x << 1] += lazy[x];
    lazy[x << 1 | 1] += lazy[x];
    tree[x << 1] += lazy[x];
    tree[x << 1 | 1] += lazy[x];
    lazy[x] = 0;
  }
}
void update(int x, int l, int r, int L, int R, int val) {
  if (L <= l && R >= r) {
    tree[x] += val;
    lazy[x] += val;
    return;
  }
  pushdown(x);
  int mid = (l + r) >> 1;
  if (L <= mid) update(x << 1, l, mid, L, R, val);
  if (R > mid) update(x << 1 | 1, mid + 1, r, L, R, val);
  pushup(x);
}
int n, r, ans;
int main() {
  n = read(), r = read();
  for (int i = 1; i <= n; i++) {
    int x = read(), y = read();
    tran(x, y);
    p.push_back(Point(x, y, 0));
    p.push_back(Point(x + 2 * r, y + 2 * r, 1));
  }
  sort(p.begin(), p.end());
  int sz = p.size();
  for (register int i = 0; i < sz; i++) {
    Point cur = p[i];
    if (!cur.c) {
      update(1, 0, 4 * dt, cur.x, cur.x + 2 * r, 1);
      ans = max(ans, tree[1]);
    } else {
      update(1, 0, 4 * dt, cur.x - 2 * r, cur.x, -1);
      ans = max(ans, tree[1]);
    }
  }
  printf("%d", ans);
  return 0;
}
