#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int main() {
  int n;
  double d;
  while (scanf("%d%lf", &n, &d) == 2) {
    vector<pair<double, int> > ev;
    for (int i = (0); i <= ((n)-1); ++i) {
      double x, y, r;
      scanf("%lf%lf%lf", &x, &y, &r);
      double cd = sqrt(((x) * (x)) + ((y) * (y)));
      double bang = atan2(y, x);
      while (bang < 0) bang += 2 * pi;
      int start = (int)ceil((cd - r) / d - 1e-9);
      int end = (int)floor((cd + r) / d + 1e-9);
      for (int j = (start); j <= (end); ++j) {
        double zd = d * j;
        if (((zd) * (zd)) + ((cd) * (cd)) - ((r) * (r)) < 0) continue;
        double ang =
            acos((((zd) * (zd)) + ((cd) * (cd)) - ((r) * (r))) / (2 * zd * cd));
        double u = bang - ang, v = bang + ang;
        while (u < 0) u += 2 * pi;
        while (v > 2 * pi) v -= 2 * pi;
        if (u < v + 1e-9) {
          if (u > v) swap(u, v);
          ev.push_back(make_pair(u, -1)), ev.push_back(make_pair(v, +1));
        } else {
          ev.push_back(make_pair(u, -1)), ev.push_back(make_pair(2 * pi, +1));
          ev.push_back(make_pair(0, -1)), ev.push_back(make_pair(v, +1));
        }
      }
    }
    sort((ev).begin(), (ev).end());
    int sum = 0;
    int msum = 0;
    for (auto x : ev) {
      sum += -x.second;
      msum = max(msum, sum);
    }
    cout << msum << endl;
  }
  return 0;
}
