#include <bits/stdc++.h>
using namespace std;
const double PI = atan2l(0, -1);
const long double eps = 1e-7;
const int maxn = 50000;
int x[maxn], y[maxn], r[maxn];
long double norm(long double x) {
  while (x < 0) x += 2 * PI;
  while (x > 2 * PI + eps) x -= 2 * PI;
  return x;
}
bool comp(const pair<long double, int> &p1, const pair<long double, int> &p2) {
  if (fabs(p1.first - p2.first) > eps) return p1.first < p2.first;
  return p1.second > p2.second;
}
int main() {
  int N, D;
  scanf("%d%d", &N, &D);
  for (int i = 0; i < (int)(N); ++i) scanf("%d%d%d", &x[i], &y[i], &r[i]);
  vector<pair<long double, int> > evs;
  for (int i = 0; i < (int)(N); ++i) {
    long double dd = sqrt(1.0 * x[i] * x[i] + y[i] * y[i]);
    int k = int(floor((dd - r[i]) / D));
    for (int j = k;; ++j) {
      long double kd = j * D;
      if (kd < dd - r[i] - eps) continue;
      if (kd > dd + r[i] + eps) break;
      long double alpha =
          acosl((kd * kd + dd * dd - r[i] * r[i]) / (2 * kd * dd));
      if (alpha != alpha) alpha = 0;
      long double beta = atan2l(1.0 * y[i], 1.0 * x[i]);
      long double l = norm(beta - alpha), r = norm(beta + alpha);
      if (l < r + eps) {
        evs.push_back(make_pair(l, 1));
        evs.push_back(make_pair(r, -1));
      } else {
        evs.push_back(make_pair(l, 1));
        evs.push_back(make_pair(2 * PI, -1));
        evs.push_back(make_pair(0, 1));
        evs.push_back(make_pair(r, -1));
      }
    }
  }
  sort((evs).begin(), (evs).end(), comp);
  int b = 0;
  int ans = 0;
  for (int i = 0; i < (int)(evs.size()); ++i) {
    b += evs[i].second;
    ans = max(ans, b);
  }
  cout << ans << '\n';
  return 0;
}
