#include <bits/stdc++.h>
using namespace std;
const int base = 2e6 + 1;
const int maxn = 6e5 + 5;
vector<int> p[2 * base];
int n, m, k, q[maxn];
struct TSegmentTree {
  int L[4 * maxn], H[4 * maxn];
  int sum[4 * maxn], Lazy[4 * maxn];
  int leaf[maxn];
  void Build(int x, int low, int high) {
    L[x] = low;
    H[x] = high;
    if (low == high) {
      sum[x] = 0;
      Lazy[x] = 0;
      leaf[low] = x;
    } else {
      int mid = (low + high) / 2;
      Build(2 * x, low, mid);
      Build(2 * x + 1, mid + 1, high);
      sum[x] = max(sum[2 * x], sum[2 * x + 1]);
      Lazy[x] = 0;
    }
  }
  void Down(int x) {
    Lazy[x * 2] += Lazy[x];
    sum[x * 2] += Lazy[x];
    Lazy[x * 2 + 1] += Lazy[x];
    sum[x * 2 + 1] += Lazy[x];
    Lazy[x] = 0;
  }
  void Update(int x, int l, int r, int w) {
    if (r < L[x] || l > H[x]) return;
    if (l <= L[x] && H[x] <= r) {
      sum[x] += w;
      Lazy[x] += w;
      return;
    }
    Down(x);
    Update(2 * x, l, r, w);
    Update(2 * x + 1, l, r, w);
    sum[x] = max(sum[2 * x], sum[2 * x + 1]);
  }
  int qi, qj;
  int Request(int x) {
    if (H[x] < qi || L[x] > qj) return 0;
    if (qi <= L[x] && H[x] <= qj) return sum[x];
    Down(x);
    return max(Request(2 * x), Request(2 * x + 1));
  }
  int Query(int l, int r) {
    qi = l;
    qj = r;
    return Request(1);
  }
} ST;
void Input() {
  cin >> n >> k;
  m = 0;
  k *= 2;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    int u = x - y + base, v = x + y + base;
    p[u].push_back(v);
    q[++m] = max(1, v - k);
    q[++m] = v;
  }
  sort(q + 1, q + 1 + m);
}
void Solve() {
  int res = 0;
  ST.Build(1, 1, m);
  for (int i = 1; i <= k + 1; i++) {
    for (int a : p[i]) {
      int l = lower_bound(q + 1, q + 1 + m, max(1, a - k)) - q;
      int r = upper_bound(q + 1, q + 1 + m, a) - q - 1;
      ST.Update(1, l, r, 1);
    }
    res = max(res, ST.Query(1, m));
  }
  for (int i = k + 1; i < 2 * base; i++) {
    int j = i - k - 1;
    for (int a : p[j]) {
      int l = lower_bound(q + 1, q + 1 + m, max(1, a - k)) - q;
      int r = upper_bound(q + 1, q + 1 + m, a) - q - 1;
      ST.Update(1, l, r, -1);
    }
    for (int a : p[i]) {
      int l = lower_bound(q + 1, q + 1 + m, max(1, a - k)) - q;
      int r = upper_bound(q + 1, q + 1 + m, a) - q - 1;
      ST.Update(1, l, r, 1);
    }
    res = max(res, ST.Query(1, m));
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Input();
  Solve();
}
