#include <bits/stdc++.h>
using namespace std;
int n, R, Max[6000021 * 4], lz[6000021 * 4], cnt;
struct line {
  int l, r, pos, y;
  line(int a = 0, int b = 0, int c = 0, int d = 0) : l(a), r(b), pos(c), y(d) {}
  bool operator<(const line& z) const { return y < z.y; }
} ln[300021 * 4];
void push_up(int u) { Max[u] = max(Max[u << 1], Max[u << 1 | 1]); }
void push_down(int u) {
  if (!lz[u]) return;
  lz[u << 1 | 1] += lz[u];
  lz[u << 1] += lz[u];
  Max[u << 1 | 1] += lz[u];
  Max[u << 1] += lz[u];
  lz[u] = 0;
}
void update(int u, int l, int r, int x, int y, int add) {
  if (l == x && r == y) {
    lz[u] += add;
    Max[u] += add;
    return;
  }
  int mid = l + r >> 1;
  push_down(u);
  if (x > mid)
    update(u << 1 | 1, mid + 1, r, x, y, add);
  else if (y <= mid)
    update(u << 1, l, mid, x, y, add);
  else
    update(u << 1, l, mid, x, mid, add),
        update(u << 1 | 1, mid + 1, r, mid + 1, y, add);
  push_up(u);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> R;
  for (int a, b, x, y, i = 1; i <= n; i++) {
    cin >> a >> b;
    x = a + b;
    y = a - b;
    ln[++cnt] = line(x + 3000003 - R, x + 3000003 + R, 1, y - R);
    ln[++cnt] = line(x + 3000003 - R, x + 3000003 + R, -1, y + R + 1);
  }
  sort(ln + 1, ln + 1 + cnt);
  int last = 1, ans = 0;
  for (int i = 1; i <= cnt; i++) {
    update(1, 1, 6000006, ln[i].l, ln[i].r, ln[i].pos);
    if (i != n && ln[i].y == ln[i + 1].y) continue;
    ans = max(ans, Max[1]);
  }
  cout << ans;
  return 0;
}
