#include <bits/stdc++.h>
using namespace std;
const int offsetx = 1000000;
const int offsety = 1000000;
const int offsety2 = 2000000;
const int maxx = 5000010 - 5;
const int maxy = 5000010 - 5;
struct P {
  int x, y, w;
  bool operator<(const P& rhs) const {
    return x != rhs.x ? x < rhs.x : (y != rhs.y ? y < rhs.y : false);
  }
};
struct SegTree {
  int maxi[(5000010 << 2)], lazy[(5000010 << 2)];
  inline int ls(int rt) { return rt << 1; }
  inline int rs(int rt) { return rt << 1 | 1; }
  void PushUp(int rt) { maxi[rt] = max(maxi[ls(rt)], maxi[rs(rt)]); }
  void PushDown(int rt) {
    if (lazy[rt]) {
      lazy[ls(rt)] += lazy[rt];
      lazy[rs(rt)] += lazy[rt];
      maxi[ls(rt)] += lazy[rt];
      maxi[rs(rt)] += lazy[rt];
      lazy[rt] = 0;
    }
  }
  void Add(int rt, int l, int r, int L, int R, int v) {
    if (L <= l && r <= R) {
      lazy[rt] += v;
      maxi[rt] += v;
    } else {
      int mid = (l + r) >> 1;
      PushDown(rt);
      if (L <= mid) Add(ls(rt), l, mid, L, R, v);
      if (mid < R) Add(rs(rt), mid + 1, r, L, R, v);
      PushUp(rt);
    }
  }
  int Max() { return maxi[1]; }
};
int main() {
  int n, r;
  static P points[300010 * 4];
  static SegTree sgt;
  scanf("%d%d", &n, &r);
  r <<= 1;
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    x += offsetx;
    y += offsety;
    points[i] = P{r + x + y + 1, r + x - y + offsety2 + 1, 1};
  }
  for (int i = 0; i < n; ++i) {
    points[i + n] = P{points[i].x - r, points[i].y - r, 1};
    points[i + 2 * n] = P{points[i].x - r, points[i].y + 1, -1};
    points[i + 3 * n] = P{points[i].x + 1, points[i].y - r, -1};
    ++points[i].x;
    ++points[i].y;
  }
  n <<= 2;
  sort(points, points + n);
  int ans = 0;
  int i = 0;
  while (i < n) {
    int nowx = points[i].x;
    for (; i < n && points[i].x == nowx; ++i) {
      sgt.Add(1, 1, maxy, points[i].y, maxy, points[i].w);
    }
    ans = max(ans, sgt.Max());
  }
  printf("%d", ans);
  return 0;
}
