#include <bits/stdc++.h>
using namespace std;
char buf[1 << 23], *fc = buf, *tc = buf;
inline char gc() {
  if (fc == tc) {
    tc = (fc = buf) + fread(buf, 1, 1 << 23, stdin);
    if (fc == tc) return EOF;
  }
  return *fc++;
}
inline int read(int x = 0, int f = 1, char ch = '0') {
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f * x;
}
const int N = 6e5 + 7;
int n, C;
int Y[N], tot, ntot;
struct node {
  int x1, y1, y2, val;
  bool operator<(const node &n2) const {
    return x1 == n2.x1 ? val < n2.val : x1 < n2.x1;
  }
  node(int x1 = 0, int y1 = 0, int y2 = 0, int val = 0)
      : x1(x1), y1(y1), y2(y2), val(val){};
} a[N];
int v[N << 2], tag[N << 2];
inline void pushup(int x) { v[x] = max(v[x << 1], v[x << 1 | 1]); }
inline void pushdown(int x) {
  if (!tag[x]) return;
  tag[x << 1] += tag[x];
  tag[x << 1 | 1] += tag[x];
  v[x << 1] += tag[x];
  v[x << 1 | 1] += tag[x];
  tag[x] = 0;
}
void update(int x, int l, int r, int ql, int qr, int d) {
  if (ql <= l && r <= qr) {
    v[x] += d;
    tag[x] += d;
    return;
  }
  pushdown(x);
  int mid = l + r >> 1;
  if (ql <= mid) update(x << 1, l, mid, ql, qr, d);
  if (qr > mid) update(x << 1 | 1, mid + 1, r, ql, qr, d);
  pushup(x);
}
int main() {
  n = read();
  C = read();
  for (register int i = (1); i <= (n); ++i) {
    int t1 = read(), t2 = read();
    int x = t1 - t2, y = t1 + t2;
    int x1 = x - C, x2 = x + C, y1 = y - C, y2 = y + C;
    Y[++ntot] = y1;
    Y[++ntot] = y2;
    a[++tot] = node(x1, y1, y2, 1);
    a[++tot] = node(x2 + 1, y1, y2, -1);
  }
  sort(a + 1, a + tot + 1);
  sort(Y + 1, Y + ntot + 1);
  ntot = unique(Y + 1, Y + ntot + 1) - Y - 1;
  int ans = 0;
  for (register int i = (1); i <= (tot); ++i) {
    int y1 = lower_bound(Y + 1, Y + ntot + 1, a[i].y1) - Y;
    int y2 = lower_bound(Y + 1, Y + ntot + 1, a[i].y2) - Y;
    update(1, 1, ntot, y1, y2, a[i].val);
    ans = max(ans, v[1]);
  }
  printf("%d\n", ans);
  return 0;
}
