#include <bits/stdc++.h>
using namespace std;
const int Max = 5100000;
const int def = 0x3f3f3f3f;
int laz[Max << 2], tree[Max << 2];
struct part {
  int x;
  int yl, yu;
  int val;
  part(int x, int yl, int yu, int val) {
    this->x = x;
    this->yl = yl;
    this->yu = yu;
    this->val = val;
  }
};
vector<part> v;
int cmp(part x, part y) { return x.x < y.x; }
void pushdown(int k) {
  if (laz[k]) {
    tree[k << 1] += laz[k];
    tree[k << 1 | 1] += laz[k];
    laz[k << 1] += laz[k];
    laz[k << 1 | 1] += laz[k];
    laz[k] = 0;
  }
}
void pushup(int k) { tree[k] = max(tree[k << 1], tree[k << 1 | 1]); }
void add(int L, int R, int val, int l, int r, int k) {
  if (l >= L && r <= R) {
    tree[k] += val;
    laz[k] += val;
    return;
  }
  pushdown(k);
  int mid = (l + r) >> 1;
  if (L <= mid) {
    add(L, R, val, l, mid, k << 1);
  }
  if (R >= mid + 1) {
    add(L, R, val, mid + 1, r, k << 1 | 1);
  }
  pushup(k);
}
int getmax(int l, int r, int k) {
  if (l == r) return tree[k];
  pushdown(k);
  int mid = (l + r) >> 1;
  if (tree[k << 1] > tree[k << 1 | 1])
    return getmax(l, mid, k << 1);
  else
    return getmax(mid + 1, r, k << 1 | 1);
}
int main() {
  int i, j, h;
  int n, m, r;
  scanf("%d %d", &n, &r);
  int d = 2000001;
  int x, y;
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &x, &y);
    v.push_back(part(x + y, y - x - 2 * r + d, y - x + d, 1));
    v.push_back(part(x + y + r * 2 + 1, y - x - 2 * r + d, y - x + d, -1));
  }
  int shuchu = 0;
  sort(v.begin(), v.end(), cmp);
  for (i = 0; i < v.size(); i++) {
    add(v[i].yl, v[i].yu, v[i].val, 1, Max - 1, 1);
    if (i == v.size() - 1 || v[i].x != v[i + 1].x) {
      shuchu = max(shuchu, getmax(1, Max - 1, 1));
    }
  }
  printf("%d\n", shuchu);
}
