#include <bits/stdc++.h>
using namespace std;
int n, d;
vector<pair<double, int> > v;
double cuad(double x) { return x * x; }
double normaliza(double a) {
  while (a > M_PI) a -= 2 * M_PI;
  while (a < -M_PI) a += 2 * M_PI;
  return a;
}
double error = 1e-9;
int main() {
  cin >> n >> d;
  int cuantos = 0;
  for (int i = 0; i < n; i++) {
    double x, y;
    cin >> x >> y;
    std::complex<double> p(x, y);
    int r;
    cin >> r;
    int inf = (abs(p) - r) / d;
    while (d * inf < abs(p) - r) inf++;
    int sup = (abs(p) + r) / d + 2;
    while (d * sup > abs(p) + r) sup--;
    if (inf > sup) continue;
    for (int prod = inf; prod <= sup; prod++) {
      double dist = d * prod;
      double a =
          acos(-(cuad(r) - cuad(abs(p)) - cuad(dist)) / (2 * abs(p) * dist));
      double amas = normaliza(arg(p) - a);
      double amenos = normaliza(arg(p) + a + error);
      v.push_back(pair<double, int>(amas, +1));
      v.push_back(pair<double, int>(amenos, -1));
      if (amas >= 0 and amenos < 0 and x < 0) cuantos++;
    }
  }
  sort(v.begin(), v.end());
  int sol = cuantos;
  for (int i = 0; i < int(v.size()); i++) {
    cuantos += v[i].second;
    sol = max(sol, cuantos);
  }
  cout << sol << endl;
}
