#include <bits/stdc++.h>
using namespace std;
int n, cnt, ans;
vector<pair<double, int> > q;
double d, lt, rt, dist, dist2, alpha, theta, D, TP = 2.0 * acos(-1.0);
vector<double> first, second, r;
double norm(double t) {
  while (t < 0) t += TP;
  while (t > TP) t -= TP;
  return t;
}
int main(int argc, char const* argv[]) {
  ios::sync_with_stdio(false);
  cin >> n >> d;
  first = vector<double>(n), second = vector<double>(n), r = vector<double>(n);
  for (int i = 0; i < n; i += 1) cin >> first[i] >> second[i] >> r[i];
  for (int i = 0; i < n; i += 1) {
    dist2 = first[i] * first[i] + second[i] * second[i];
    dist = sqrt(dist2);
    theta = atan2(second[i], first[i]);
    int k = int((dist - r[i]) / d);
    while (double(k) * d + r[i] < dist) k++;
    for (D = double(k) * d; D <= dist + r[i] + (1e-9); D += d) {
      alpha = acos((D * D + dist2 - r[i] * r[i]) / (2.0 * D * dist));
      lt = norm(theta - alpha), rt = norm(theta + alpha);
      if (lt <= rt) {
        q.push_back(make_pair(lt, -1));
        q.push_back(make_pair(rt, 1));
      } else {
        q.push_back(make_pair(0.0, -1));
        q.push_back(make_pair(rt, 1));
        q.push_back(make_pair(lt, -1));
        q.push_back(make_pair(TP, 1));
      }
    }
  }
  sort(q.begin(), q.end());
  cnt = 0;
  ans = 0;
  for (int i = 0; i < (int)(q.size()); i += 1) {
    if (q[i].second == -1)
      cnt++;
    else
      cnt--;
    ans = max(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}
