#include <bits/stdc++.h>
using namespace std;
long n;
double d, x, y, r, span, t;
double ang;
long at0;
vector<pair<double, long> > evs;
double temp;
long ans;
double ev(double e) {
  while (e < 0) e += 2 * M_PI;
  while (e >= 2 * M_PI) e -= 2 * M_PI;
  return e;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y >> r;
    span = 0;
    t = x * x + y * y;
    t = sqrt(t);
    while (true) {
      span += d;
      if (span > t + r + 1e-11) break;
      if (span <= t - r - 1e-11) continue;
      ang = atan2(y, x);
      temp = t * t + span * span - r * r;
      temp = temp / t / span;
      temp /= 2;
      temp = acos(temp);
      if (ang - temp < 0 && ang + temp > 0) ++at0;
      evs.push_back(make_pair(ev(ang - temp), -1));
      evs.push_back(make_pair(ev(ang + temp), 1));
    }
  }
  sort(evs.begin(), evs.end());
  ans = at0;
  for (int i = 0; i < evs.size(); i++) {
    at0 -= evs[i].second;
    ans = max(ans, at0);
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
