#include <bits/stdc++.h>
using namespace std;
const int kn = 1e6 + 6;
int n, R, it[16 * kn], lazy[16 * kn], ans = 1;
pair<int, int> coor[300001];
void down(int id) {
  lazy[id << 1] += lazy[id];
  lazy[(id << 1) | 1] += lazy[id];
  it[id << 1] += lazy[id];
  it[(id << 1) | 1] += lazy[id];
  lazy[id] = 0;
}
void upd(int id, int l, int r, int L, int R, int val) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    it[id] += val;
    lazy[id] += val;
    return;
  }
  if (lazy[id] != 0) down(id);
  int mid = (l + r) >> 1;
  upd(id << 1, l, mid, L, R, val);
  upd((id << 1) | 1, mid + 1, r, L, R, val);
  it[id] = max(it[id << 1], it[(id << 1) | 1]);
}
int main() {
  scanf("%d %d", &n, &R);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &coor[i].first, &coor[i].second);
    int tmp = coor[i].first + coor[i].second,
        tmp0 = coor[i].first - coor[i].second + 2e6 + 1;
    coor[i] = {tmp, tmp0};
  }
  sort(coor + 1, coor + n + 1);
  int l = 0;
  coor[0].first = -1e7;
  for (int i = 1; i <= n; i++) {
    while (coor[l].first < coor[i].first - 2 * R) {
      if (l != 0)
        upd(1, 1, 4e6 + 1, coor[l].second, min(coor[l].second + 2 * R, 4000001),
            -1);
      l++;
    }
    upd(1, 1, 4e6 + 1, coor[i].second, min(coor[i].second + 2 * R, 4000001), 1);
    ans = max(ans, it[1]);
  }
  printf("%d\n", ans);
}
