#include <bits/stdc++.h>
using namespace std;
class ST {
  long long int tree[10000000];
  long long int lazy[10000000];

 public:
  void build(int a, int b, int node) {
    tree[node] = 0;
    lazy[node] = 0;
    if (a == b) return;
    int mid = (a + b + 4000000) / 2 - 2000000;
    build(a, mid, 2 * node);
    build(mid + 1, b, 2 * node + 1);
  }
  void propagate(int a, int b, int node) {
    tree[node] += lazy[node];
    if (a != b) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  void update(int a, int b, int node, int x, int y, long long int val) {
    propagate(a, b, node);
    if (b < x || y < a) return;
    if (x <= a && b <= y) {
      lazy[node] += val;
      propagate(a, b, node);
      return;
    }
    int mid = (a + b + 4000000) / 2 - 2000000;
    update(a, mid, 2 * node, x, y, val);
    update(mid + 1, b, 2 * node + 1, x, y, val);
    tree[node] = max(tree[2 * node], tree[2 * node + 1]);
  }
  long long int query() { return tree[1]; }
};
int main() {
  int n;
  long long int r;
  scanf("%d %lld", &n, &r);
  vector<pair<long long int, long long int> > V;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    scanf("%lld %lld", &a, &b);
    V.push_back(pair<long long int, long long int>(a + b, a - b));
  }
  ST *S = new ST();
  S->build(-2000000, 2000000, 1);
  sort(V.begin(), V.end());
  int ptr = 0;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    while (V[ptr].first < V[i].first - 2 * r) {
      S->update(-2000000, 2000000, 1, V[ptr].second - 2 * r, V[ptr].second, -1);
      ptr++;
    }
    S->update(-2000000, 2000000, 1, V[i].second - 2 * r, V[i].second, 1);
    ans = max(ans, S->query());
  }
  printf("%lld\n", ans);
  return 0;
}
