#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
};
bool follow_y(const point& a, const point& b) { return a.y < b.y; }
bool follow_x(const point& a, const point& b) { return a.x < b.x; }
void push(int node, vector<int>& st, vector<int>& lazy) {
  if (!lazy[node]) return;
  st[node << 1] += lazy[node];
  lazy[node << 1] += lazy[node];
  st[node << 1 | 1] += lazy[node];
  lazy[node << 1 | 1] += lazy[node];
  lazy[node] = 0;
}
void update_tree(int node, int l, int r, int u, int v, int val, vector<int>& st,
                 vector<int>& lazy) {
  if (v < l || r < u) return;
  if (u <= l && r <= v) {
    st[node] += val;
    lazy[node] += val;
    return;
  }
  int mid = (l + r) >> 1;
  push(node, st, lazy);
  update_tree(node << 1, l, mid, u, v, val, st, lazy);
  update_tree(node << 1 | 1, mid + 1, r, u, v, val, st, lazy);
  st[node] = max(st[node << 1], st[node << 1 | 1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, r;
  cin >> n >> r;
  vector<point> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i].x >> a[i].y;
  for (int i = 0; i < n; ++i) {
    point tmp;
    tmp.y = a[i].y - a[i].x;
    tmp.x = a[i].x + a[i].y;
    a[i] = tmp;
  }
  sort(a.begin(), a.end(), follow_y);
  int cnt = 1;
  for (int i = 1; i < n; ++i) cnt += (a[i].y != a[i - 1].y);
  vector<int> o_y(cnt + 1), st(4 * cnt + 1, 0), lazy(4 * n + 1, 0);
  o_y[1] = a[0].y;
  for (int i = 1, j = 2; i < n; ++i)
    if (a[i].y != a[i - 1].y) o_y[j++] = a[i].y;
  sort(a.begin(), a.end(), follow_x);
  r *= 2;
  int ans = 1;
  for (int i = 0, j = -1; i < n; ++i) {
    if (i) {
      int right =
          lower_bound(o_y.begin() + 1, o_y.end(), a[i - 1].y) - o_y.begin();
      int left =
          lower_bound(o_y.begin() + 1, o_y.end(), a[i - 1].y - r) - o_y.begin();
      update_tree(1, 1, cnt, left, right, -1, st, lazy);
    }
    int k = j + 1;
    while (k < n && a[k].x - a[i].x <= r) ++k;
    for (int u = j + 1; u < k; ++u) {
      int right = lower_bound(o_y.begin() + 1, o_y.end(), a[u].y) - o_y.begin();
      int left =
          lower_bound(o_y.begin() + 1, o_y.end(), a[u].y - r) - o_y.begin();
      update_tree(1, 1, cnt, left, right, 1, st, lazy);
    }
    ans = max(ans, st[1]);
    j = k - 1;
  }
  cout << ans << '\n';
  return 0;
}
