#include <bits/stdc++.h>
using namespace std;
long long inf = 4e18, mod = 1e9 + 7;
vector<pair<pair<long long, long long>, pair<long long, long long>>> v;
int segt[4 * 6000000 + 5], lazy[4 * 6000000 + 5];
void push(int v, int l, int r) {
  segt[v] += lazy[v];
  if (l != r) {
    lazy[2 * v] += lazy[v];
    lazy[2 * v + 1] += lazy[v];
  }
  lazy[v] = 0;
}
void update_range(int v, int l, int r, int qs, int qe, int x) {
  push(v, l, r);
  if (l > qe || r < qs) return;
  if (qs <= l && r <= qe) {
    lazy[v] += x;
    push(v, l, r);
    return;
  }
  int m = (l + r) / 2;
  update_range(2 * v, l, m, qs, qe, x);
  update_range(2 * v + 1, m + 1, r, qs, qe, x);
  segt[v] = max(segt[2 * v], segt[2 * v + 1]);
}
int query(int v, int l, int r, int qs, int qe) {
  push(v, l, r);
  if (l > qe || r < qs) return 0;
  if (qs <= l && r <= qe) return segt[v];
  int m = (l + r) / 2;
  int val1 = query(2 * v, l, m, qs, qe);
  int val2 = query(2 * v + 1, m + 1, r, qs, qe);
  return max(val1, val2);
}
void solve() {
  int n, r;
  cin >> n >> r;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    int X = x + y, Y = y - x;
    int lx, ly, ux, uy;
    lx = X - r, ux = X + r, ly = Y - r, uy = Y + r;
    lx += 3000000;
    ux += 3000000;
    ly += 3000000;
    uy += 3000000;
    v.push_back({{ly, 0}, {lx, ux}});
    v.push_back({{uy, 1}, {lx, ux}});
  }
  sort(v.begin(), v.end());
  int res = 0;
  for (auto it : v) {
    if (it.first.second == 0)
      update_range(1, 0, 6000000, it.second.first, it.second.second, 1);
    else
      update_range(1, 0, 6000000, it.second.first, it.second.second, -1);
    int val = query(1, 0, 6000000, 0, 6000000);
    res = max(res, val);
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
}
