#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double EPS = 1e-8, INF = 1e12, PI = acos(-1.0);
inline double fix(double a) {
  if (a >= 2 * PI) a -= 2 * PI;
  if (a < 0) a += 2 * PI;
  return a;
}
int n, d;
complex<double> c[20000];
int r[20000];
int main() {
  scanf("%d%d", &n, &d);
  vector<pair<double, int> > event;
  for (int i = 0; i < (int)n; i++) {
    int x, y;
    scanf("%d%d%d", &x, &y, r + i);
    c[i] = complex<double>(x, y);
    double dist = abs(c[i]);
    double lim = dist + r[i] + EPS;
    for (int k = (int)ceil((dist - r[i]) / d - EPS) * d; k < lim; k += d) {
      double t = (dist * dist + k * k - r[i] * r[i]) / 2 / dist / k;
      t = acos(t);
      double a = fix(arg(c[i]) - t);
      double b = fix(arg(c[i]) + t);
      event.push_back(make_pair(a - EPS, 1));
      event.push_back(make_pair(b + EPS, -1));
      if (a > b) event.push_back(make_pair(-EPS, 1));
    }
  }
  sort((event).begin(), (event).end());
  int ans = 0;
  int cur = 0;
  for (int e = 0; e < (int)event.size(); e++) {
    cur += event[e].second;
    ans = max(ans, cur);
  }
  cout << ans << endl;
  return 0;
}
