#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= MOD;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
template <typename t1, typename t2>
inline bool upmax(t1 &a, t2 b) {
  if (a < (t1)b) {
    a = (t1)b;
    return true;
  } else
    return false;
}
template <typename t1, typename t2>
inline bool upmin(t1 &a, t2 b) {
  if (a > (t1)b) {
    a = (t1)b;
    return true;
  } else
    return false;
}
template <typename T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
inline T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int dkx[] = {-1, -1, 1, 1, -2, -2, 2, 2};
int dky[] = {-2, 2, -2, 2, -1, 1, -1, 1};
const int INF = 1000000404;
const long long LINF = 1e18 * (1ll);
const long double PI = 3.14159265358979323846;
const long double EPS = 1e-9;
const int SQ = 318;
int timer = 0;
pair<int, int> a[5000000];
int t[5000000 * 4];
int lazy[5000000 * 4];
int n;
int r;
void push(int v, int tl, int tr) {
  if (tl != tr) lazy[v + v] += lazy[v];
  if (tl != tr) lazy[v + v + 1] += lazy[v];
  t[v] += lazy[v];
  lazy[v] = 0;
}
void update(int l, int r, int delta, int v = 1, int tl = 1,
            int tr = 5000000 - 1) {
  push(v, tl, tr);
  if (l > tr || r < tl) return;
  if (l <= tl && tr <= r) {
    lazy[v] += delta;
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) >> 1;
  update(l, r, delta, v + v, tl, tm);
  update(l, r, delta, v + v + 1, tm + 1, tr);
  t[v] = max(t[v + v], t[v + v + 1]);
}
void get(int pos, int v = 1, int tl = 1, int tr = 5000000 - 1) {
  push(v, tl, tr);
  if (tl == tr) {
    cout << t[v] << ' ';
  } else {
    int tm = (tl + tr) >> 1;
    if (pos <= tm)
      get(pos, v + v, tl, tm);
    else
      get(pos, v + v + 1, tm + 1, tr);
  }
}
int getmax() { return t[1]; }
int OFFSET = 2000001;
void solve() {
  cin >> n >> r;
  r = 2 * r;
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    int x, y;
    cin >> x >> y;
    a[i].first = x + y;
    a[i].second = x - y + OFFSET;
  }
  sort(a + 1, a + n + 1);
  queue<int> q;
  int ans = 0;
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    while (!q.empty() && a[q.front()].first + r < a[i].first) {
      update(a[q.front()].second, a[q.front()].second + r, -1);
      q.pop();
    }
    q.push(i);
    update(a[i].second, a[i].second + r, 1);
    ans = max(ans, getmax());
  }
  cout << ans << endl;
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
