#include <bits/stdc++.h>
using namespace std;
double PI;
pair<complex<double>, complex<double> > inter(complex<double> a, double ra,
                                              complex<double> b, double rb) {
  double L2 = norm(b - a), L = sqrt(L2),
         A = 0.5 * sqrt((L + ra + rb) * (L + ra - rb) * (L - ra + rb) *
                        (-L + ra + rb));
  complex<double> p = (a + b) / 2.0 + (b - a) * (ra * ra - rb * rb) / 2.0 / L2;
  complex<double> u = A / L2 * complex<double>((b - a).imag(), -(b - a).real());
  return pair<complex<double>, complex<double> >(p + u, p - u);
}
const int N = 1e6 + 100;
double r[N];
complex<double> p[N];
pair<double, double> t[N];
int tN;
double a[N];
int aN;
void add(complex<double> a, double ra, complex<double> b, double rb) {
  double L = abs(b - a);
  int l;
  if (rb >= L)
    for (l = 1; l * ra + L <= rb; l++) t[tN++] = pair<double, double>(-PI, PI);
  else
    l = ceil((L - rb) / ra);
  for (; l * ra <= rb + L; l++) {
    auto res = inter(a, l * ra, b, rb);
    ::a[aN++] = arg(res.first - a);
    ::a[aN++] = arg(res.second - a);
    t[tN++] = pair<double, double>(::a[aN - 2], ::a[aN - 1]);
  }
}
int cnt[N];
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  PI = acos(-1);
  int n;
  double d;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    double x, y;
    cin >> x >> y;
    p[i] = complex<double>(x, y);
    cin >> r[i];
    add(complex<double>(0, 0), d, p[i], r[i]);
  }
  a[aN++] = PI;
  a[aN++] = -PI;
  sort(a, a + aN);
  aN = unique(a, a + aN) - a;
  for (int i = 0; i < tN; i++) {
    double x = t[i].first, y = t[i].second;
    if (x > y) {
      cnt[lower_bound(a, a + aN, x) - a]++;
      cnt[0]++;
      cnt[upper_bound(a, a + aN, y) - a]--;
    } else {
      cnt[lower_bound(a, a + aN, x) - a]++;
      cnt[upper_bound(a, a + aN, y) - a]--;
    }
  }
  int cur = 0, ans = 0;
  for (int i = 0; i < aN; i++) {
    cur += cnt[i];
    ans = max(ans, cur);
  }
  cout << ans << endl;
}
