#include <bits/stdc++.h>
using namespace std;
struct Tree {
 private:
  const int inf = 1 << 30;
  vector<int> T, lazy;
  int n;
  int create(int id, int l, int r, vector<int> &a) {
    if (r - l == 1) return T[id] = a[l];
    int m = (l + r) >> 1;
    return T[id] = max(create(2 * id, l, m, a), create(2 * id + 1, m, r, a));
  }
  void push(int id) {
    for (int x : {2 * id, 2 * id + 1}) {
      T[x] += lazy[id];
      lazy[x] += lazy[id];
    }
    lazy[id] = 0;
  }
  int getMax(int id, int l, int r, int l1, int r1) {
    if (l == l1 && r == r1) return T[id];
    if (l1 == r1) return -inf;
    push(id);
    int m = (l + r) >> 1;
    return max(getMax((id << 1), l, m, min(l1, m), min(r1, m)),
               getMax((id << 1) + 1, m, r, max(l1, m), max(r1, m)));
  }
  int update(int id, int l, int r, int l1, int r1, int s) {
    if (l1 == r1) return T[id];
    if (l == l1 && r == r1) {
      T[id] += s;
      lazy[id] += s;
      return T[id];
    }
    push(id);
    int m = (l + r) >> 1;
    return T[id] = max(update((id << 1), l, m, min(l1, m), min(r1, m), s),
                       update((id << 1) + 1, m, r, max(l1, m), max(r1, m), s));
  }

 public:
  Tree(vector<int> &a) {
    this->n = a.size();
    T.assign(4 * n + 1, 0);
    lazy.assign(4 * n + 1, 0);
    create(1, 0, a.size(), a);
  }
  int getMax(int l, int r) { return getMax(1, 0, n, l, r); }
  void update(int l, int r, int s) { update(1, 0, n, l, r, s); }
};
const int N = 4e6 + 1;
vector<int> pts[N];
Tree T(*new vector<int>(N));
int main() {
  iostream::sync_with_stdio(false);
  int n, r;
  cin >> n >> r;
  const int M = 2e6;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    pts[x - y + M].push_back(x + y + M);
  }
  int ans = 0;
  int l = 2 * r;
  for (int x = 0; x < N; x++) {
    for (int y : pts[x]) T.update(max(y - l, 0), y + 1, 1);
    if (x - l - 1 >= 0)
      for (int y : pts[x - l - 1]) T.update(max(y - l, 0), y + 1, -1);
    ans = max(ans, T.getMax(0, N));
  }
  cout << ans << endl;
}
