#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 1000000007;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int pow(int a, int b, int c) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
struct node {
  int first, y1, y2, t;
  bool operator<(const node &a) const {
    if (first != a.first)
      return first < a.first;
    else if (y1 != a.y1)
      return y1 < a.y1;
    return t < a.t;
  }
};
vector<node> e;
int c[600010 << 2], mx[600010 << 2];
void cal(int p, int v) {
  mx[p] += v;
  c[p] += v;
}
void down(int p) {
  if (c[p]) {
    cal(p << 1, c[p]);
    cal(p << 1 | 1, c[p]);
    c[p] = 0;
  }
}
void upd(int p, int l, int r, int first, int second, int v) {
  if (l >= first && r <= second) {
    cal(p, v);
    return;
  }
  int m = (l + r) >> 1;
  down(p);
  if (first <= m) upd(p << 1, l, m, first, second, v);
  if (second > m) upd(p << 1 | 1, m + 1, r, first, second, v);
  mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
}
int main() {
  int T, ca = 0, k, i, j, n, m = 0, K;
  int r, first, second;
  scanf("%d%d", &n, &r);
  vector<int> V;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &first, &second);
    e.push_back(
        {first - second - r, first + second - r, first + second + r, 1});
    e.push_back(
        {first - second + r + 1, first + second - r, first + second + r, -1});
    V.push_back(first + second - r);
    V.push_back(first + second + r);
  }
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  sort(e.begin(), e.end());
  int ans = 0;
  for (auto &o : e) {
    int l = lower_bound(V.begin(), V.end(), o.y1) - V.begin();
    int r = lower_bound(V.begin(), V.end(), o.y2) - V.begin();
    upd(1, 0, (int)V.size() - 1, l, r, o.t);
    Max(ans, mx[1]);
  }
  printf("%d\n", ans);
}
