#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} a[300010];
struct line {
  int x, a, b, t;
} l[600010];
int n, r, ry[1000010];
inline bool cmp(const int &x, const int &y) { return x < y; }
inline bool cmp2(const line &a, const line &b) {
  return a.x < b.x || (a.x == b.x && a.t > b.t);
}
struct segment_tree {
  int mx[3000010], ad[3000010];
  inline void pushdown(int i) {
    if (ad[i]) {
      mx[i << 1 | 1] += ad[i];
      ad[i << 1 | 1] += ad[i];
      mx[i << 1] += ad[i];
      ad[i << 1] += ad[i];
      ad[i] = 0;
    }
  }
  inline void modify(int i, int L, int R, int l, int r, int x) {
    if (l <= L && r >= R) {
      ad[i] += x;
      mx[i] += x;
      return;
    }
    int mid = L + R >> 1;
    pushdown(i);
    if (l <= mid) modify(i << 1, L, mid, l, r, x);
    if (r > mid) modify(i << 1 | 1, mid + 1, R, l, r, x);
    mx[i] = max(mx[i << 1], mx[i << 1 | 1]);
  }
} A;
int main() {
  cin >> n >> r;
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    a[i].x = x + y;
    a[i].y = x - y;
  }
  int N = 0;
  for (int i = 1; i <= n; i++) ry[++N] = a[i].y - r, ry[++N] = a[i].y + r;
  sort(ry + 1, ry + N + 1, cmp);
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    int t1 = lower_bound(ry + 1, ry + N + 1, a[i].y - r) - ry;
    int t2 = lower_bound(ry + 1, ry + N + 1, a[i].y + r) - ry;
    l[++tot] = (line){a[i].x - r, t1, t2, 1};
    l[++tot] = (line){a[i].x + r, t1, t2, -1};
  }
  sort(l + 1, l + tot + 1, cmp2);
  int ans = 0, j;
  for (int i = 1; i <= tot; i = j) {
    for (j = i; l[j].x == l[i].x && l[j].t == 1;)
      A.modify(1, 1, N, l[j].a, l[j].b, l[j].t), j++;
    ans = max(ans, A.mx[1]);
    for (; l[j].x == l[i].x;) A.modify(1, 1, N, l[j].a, l[j].b, l[j].t), j++;
  }
  cout << ans << endl;
  return 0;
}
