#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
const double pi = 4 * atan(1);
double x[1100000], y[1100000], r[1100000], dir[1100000];
pair<double, double> ival[1100000];
int val[1100000];
int main() {
  int N, i, j, k, n, m, cur, ans;
  double step, d, d1, al, be;
  scanf("%d%lf", &N, &step);
  for (i = 0; i < N; i++) scanf("%lf%lf%lf", &x[i], &y[i], &r[i]);
  for (i = n = 0; i < N; i++) {
    al = atan2(y[i], x[i]);
    d = hypot(x[i], y[i]);
    k = floor((d - r[i]) / step);
    for (;; k++) {
      d1 = step * k;
      if (d1 > d + r[i] + 1e-8) break;
      if (d1 < d - r[i] - 1e-8) continue;
      be = (d * d + d1 * d1 - r[i] * r[i]) / 2 / d / d1;
      chkmax(be, -1.0);
      chkmin(be, 1.0);
      be = acos(be);
      ival[n].first = al - be;
      ival[n].second = al + be;
      while (ival[n].first > pi * 2) ival[n].first -= pi * 2;
      while (ival[n].first < 0) ival[n].first += pi * 2;
      while (ival[n].second > pi * 2) ival[n].second -= pi * 2;
      while (ival[n].second < 0) ival[n].second += pi * 2;
      n++;
    }
  }
  for (i = m = 0; i < n; i++) {
    dir[m++] = ival[i].first;
    dir[m++] = ival[i].second;
  }
  sort(dir, dir + m);
  for (i = j = 0; i < m; i++)
    if (j == 0 || dir[i] > dir[j - 1] + 1e-8) dir[j++] = dir[i];
  m = j;
  cur = 0;
  for (i = 0; i < n; i++) {
    int u = lower_bound(dir, dir + m, ival[i].first) - dir;
    int v = lower_bound(dir, dir + m, ival[i].second) - dir;
    if (u <= v)
      val[u]++, val[v + 1]--;
    else {
      cur++;
      val[v + 1]--;
      val[u]++;
    }
  }
  ans = cur;
  for (i = 0; i < m; i++) {
    cur += val[i];
    chkmax(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}
