#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 7;
int n, len, r;
int sor[MAXN * 4];
map<int, int> Hash;
struct Edge {
  int x, y, val;
} edge[MAXN * 4];
int edge_cnt = 0;
void AddEdge(int x, int y, int val) {
  edge[++edge_cnt].val = val;
  edge[edge_cnt].x = x;
  edge[edge_cnt].y = y;
  sor[edge_cnt] = y;
}
bool Cmp(Edge a, Edge b) {
  if (a.x ^ b.x) {
    return a.x < b.x;
  }
  return a.y < b.y;
}
struct LazyTag {
  int add;
  void Clean() { add = 0; }
} for_make;
LazyTag MakeTag(int add) {
  for_make.add = add;
  return for_make;
}
struct SegmentTree {
  int max;
  LazyTag tag;
} sgt[MAXN * 4];
void PushUp(int now) {
  sgt[now].max = max(sgt[(now << 1)].max, sgt[(now << 1 | 1)].max);
}
void Down(LazyTag tag, int now) {
  sgt[now].tag.add += tag.add;
  sgt[now].max += tag.add;
}
void PushDown(int now) {
  Down(sgt[now].tag, (now << 1));
  Down(sgt[now].tag, (now << 1 | 1));
  sgt[now].tag.Clean();
}
void Updata(int now_left, int now_right, int val, int now = 1, int left = 1,
            int right = len) {
  if (now_right < left || right < now_left) {
    return;
  }
  if (now_left <= left && right <= now_right) {
    Down(MakeTag(val), now);
    return;
  }
  PushDown(now);
  Updata(now_left, now_right, val, (now << 1), left, ((left + right) >> 1));
  Updata(now_left, now_right, val, (now << 1 | 1), ((left + right) >> 1) + 1,
         right);
  PushUp(now);
}
int main() {
  scanf("%d%d", &n, &r);
  if (r < 0) {
    printf("%d\n", 0);
    return 0;
  }
  r *= 2;
  int x1, y1, x, y;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x1, &y1);
    x = r + x1 + y1 + 1;
    y = r + x1 - y1 + 1;
    AddEdge(x + 1, y + 1, 1);
    AddEdge(x - r, y - r, 1);
    AddEdge(x - r, y + 1, -1);
    AddEdge(x + 1, y - r, -1);
  }
  sort(edge + 1, edge + edge_cnt + 1, Cmp);
  sort(sor + 1, sor + edge_cnt + 1);
  sor[0] = sor[1] - 1;
  len = 0;
  for (int i = 1; i <= edge_cnt; ++i) {
    if (sor[i] != sor[i - 1]) {
      Hash[sor[i]] = ++len;
    }
  }
  int answer = 0, now = 1;
  for (int i = 1; i <= edge_cnt; ++i) {
    while (edge[now].x == edge[i].x) {
      Updata(Hash[edge[now].y], len, edge[now].val);
      ++now;
    }
    answer = max(answer, sgt[1].max);
  }
  printf("%d", answer);
  return 0;
}
