#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const int NN = N * 4;
int x[N], y[N], pos_by_sub[N], pos_by_sum[N], val[N], ref_sub[N], le[N];
int tree[NN], lazy[NN];
inline bool cmp_by_sum(int i, int j) {
  return x[i] + y[i] < x[j] + y[j] || (x[i] + y[i] == x[j] + y[j] && i < j);
}
inline bool cmp_by_sub(int i, int j) {
  return x[i] - y[i] < x[j] - y[j] || (x[i] - y[i] == x[j] - y[j] && i < j);
}
void push_down(int nd, int l, int r) {
  if (lazy[nd] == 0) return;
  tree[nd] += lazy[nd];
  if (l < r) {
    int cc = nd << 1;
    lazy[cc] += lazy[nd];
    lazy[cc + 1] += lazy[nd];
  }
  lazy[nd] = 0;
}
void update(int nd, int l, int r, int tr, int ph, int v) {
  push_down(nd, l, r);
  if (r < tr || l > ph) return;
  if (tr <= l && r <= ph) {
    lazy[nd] += v;
    push_down(nd, l, r);
    return;
  }
  int m = (l + r) >> 1;
  int cc = nd << 1;
  update(cc, l, m, tr, ph, v);
  update(cc + 1, m + 1, r, tr, ph, v);
  tree[nd] = max(tree[cc], tree[cc + 1]);
}
int main() {
  int n, r;
  scanf("%d%d", &n, &r);
  r += r;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", x + i, y + i);
    pos_by_sum[i] = i;
    pos_by_sub[i] = i;
  }
  sort(pos_by_sum + 1, pos_by_sum + n + 1, cmp_by_sum);
  sort(pos_by_sub + 1, pos_by_sub + n + 1, cmp_by_sub);
  int sz = 0;
  for (int i = 1; i <= n; i++) {
    int ii = pos_by_sub[i];
    int v = x[ii] - y[ii];
    if (sz > 0 && val[sz] == v) {
      ref_sub[ii] = sz;
      continue;
    }
    val[++sz] = v;
    ref_sub[ii] = sz;
  }
  int j = 1;
  for (int i = 1; i <= sz; i++) {
    int lim = val[i] - r;
    while (j < i && val[j] < lim) j++;
    le[i] = j;
  }
  j = 1;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    int ii = pos_by_sum[i];
    int ref_idx = ref_sub[ii];
    update(1, 1, sz, le[ref_idx], ref_idx, 1);
    int lim = x[ii] + y[ii] - r;
    while (j <= i) {
      int jj = pos_by_sum[j];
      if (x[jj] + y[jj] >= lim) break;
      int ref_jdx = ref_sub[jj];
      update(1, 1, sz, le[ref_jdx], ref_jdx, -1);
      j++;
    }
    res = max(res, tree[1]);
  }
  printf("%d\n", res);
}
