#include <bits/stdc++.h>
using namespace std;
class Timer {
 private:
  string scope_name;
  chrono::high_resolution_clock::time_point start_time;

 public:
  Timer(string name) : scope_name(name) {
    start_time = chrono::high_resolution_clock::now();
  }
  ~Timer() {
    auto stop_time = chrono::high_resolution_clock::now();
    auto length =
        chrono::duration_cast<chrono::microseconds>(stop_time - start_time)
            .count();
    double mlength = double(length) * 0.001;
    ;
  }
};
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const int MAXN = 300005;
const int MAXC = 1000006 * 4 + 6;
const int sft = 1000006 * 2 + 3;
int n, r, x[MAXN], y[MAXN];
struct Query {
  int pos, l, r, type;
} query[MAXN * 2];
ostream &operator<<(ostream &_s, const Query &_p) {
  return _s << "(" << _p.pos << "," << _p.l << "," << _p.r << "," << _p.type
            << ")";
}
int seg[MAXC * 4], tag[MAXC * 4];
int getN(int o) { return tag[o] + seg[o]; }
void pull(int o) { seg[o] = max(getN(o << 1), getN(o << 1 | 1)); }
void add(int qL, int qR, int val, int o = 1, int nL = 0, int nR = MAXC) {
  if (qL < nR && qR > nL && qL < qR) {
    if (qL <= nL && nR <= qR) {
      tag[o] += val;
    } else {
      int nM = (nL + nR) >> 1;
      add(qL, qR, val, o << 1, nL, nM);
      add(qL, qR, val, o << 1 | 1, nM, nR);
      pull(o);
    }
  }
}
int qry() { return getN(1); }
int main() {
  ;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> r;
  for (int i = 0; i < n; i += 1) {
    cin >> x[i] >> y[i];
    query[i << 1] = {max(0, x[i] - y[i] - r + sft),
                     max(0, x[i] + y[i] - r + sft),
                     min(MAXC - 1, x[i] + y[i] + r + sft), 1};
    query[i << 1 | 1] = {min(MAXC - 1, x[i] - y[i] + r + sft),
                         max(0, x[i] + y[i] - r + sft),
                         min(MAXC - 1, x[i] + y[i] + r + sft), -1};
  }
  sort(query, query + n * 2, [&](Query q1, Query q2) {
    return q1.pos != q2.pos ? q1.pos < q2.pos : q1.type > q2.type;
  });
  int ans = 0;
  for (int i = 0; i < n * 2; i += 1) {
    auto q = query[i];
    ;
    ans = max(ans, qry());
    add(q.l, q.r + 1, q.type);
  }
  cout << ans << '\n';
  return 0;
}
