#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1);
vector<pair<double, double> > inv;
vector<pair<double, bool> > no;
bool cmp(pair<double, bool> a, pair<double, bool> b) {
  return a.first < b.first || a.first == b.first && a.second > b.second;
}
int main() {
  int n, i, j, L, R;
  double d, x, y, D, rr;
  double len, l, r, theta;
  int tmp = 0, ans = 0;
  scanf("%d%lf", &n, &d);
  for (i = 0; i < n; ++i) {
    scanf("%lf%lf%lf", &x, &y, &rr);
    len = sqrt((x) * (x) + (y) * (y));
    L = ceil((len - rr) / d);
    R = floor((len + rr) / d);
    double ang = atan2(y, x);
    for (j = L; j <= R; ++j) {
      D = j * d;
      theta = acos(((D) * (D) + (len) * (len) - (rr) * (rr)) / 2 / D / len);
      l = ang - theta;
      r = ang + theta;
      if ((abs(l + pi) < eps ? 0 : (l + pi) < 0 ? -1 : 1) <= 0) {
        ++tmp;
        l += 2 * pi;
      } else if ((abs(r - pi) < eps ? 0 : (r - pi) < 0 ? -1 : 1) >= 0) {
        ++tmp;
        r -= 2 * pi;
      }
      inv.push_back(make_pair(l, r));
    }
  }
  n = inv.size();
  for (i = 0; i < n; ++i) {
    no.push_back(make_pair(inv[i].first, 1));
    no.push_back(make_pair(inv[i].second, 0));
  }
  sort(no.begin(), no.end(), cmp);
  n = no.size();
  for (i = 0; i < n; ++i) {
    if (no[i].second)
      ++tmp;
    else
      --tmp;
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}
