#include <bits/stdc++.h>
using namespace std;
using DB = double;
const DB EPS = 1e-8;
const DB eps = 1e-12;
const DB PI = acos(-1);
DB sqr(DB x) { return x * x; }
struct PT {
  DB x, y;
  PT(DB x = 0, DB y = 0) : x(x), y(y) {}
  void in() { scanf("%lf%lf", &x, &y); }
  DB dis() { return sqrt(x * x + y * y); }
};
PT operator+(PT p1, PT p2) { return PT(p1.x + p2.x, p1.y + p2.y); }
PT operator-(PT p1, PT p2) { return PT(p1.x - p2.x, p1.y - p2.y); }
PT operator*(PT p, DB c) { return PT(p.x * c, p.y * c); }
PT operator/(PT p, DB c) { return PT(p.x / c, p.y / c); }
int posCirCir(PT p1, DB r1, PT p2, DB r2, PT *q) {
  DB dx, dy, d, e, f2, f;
  dx = p2.x - p1.x, dy = p2.y - p1.y;
  d = (p1 - p2).dis();
  e = (sqr(r1) - sqr(r2) + sqr(d)) / 2 / d;
  f2 = sqr(r1) - sqr(e);
  if (f2 < -EPS) return 0;
  f = sqrt(fabs(f2));
  q[0] = PT(p1.x + (e * dx - f * dy) / d, p1.y + (e * dy + f * dx) / d);
  q[1] = PT(p1.x + (e * dx + f * dy) / d, p1.y + (e * dy - f * dx) / d);
  if (f2 < EPS) return 1;
  return 2;
}
DB getAngle(PT p) { return atan2(p.y, p.x); }
const int N = 22000;
PT p[N];
DB r[N];
vector<DB> angles;
vector<pair<DB, DB>> VP;
vector<int> vi;
bool eq(DB x, DB y) { return fabs(x - y) < eps; }
void insert(DB st, DB en) {
  angles.push_back(st);
  angles.push_back(en);
  if (en > st + PI || (en < st - eps && en > st - PI)) swap(st, en);
  if (en + eps < st) {
    VP.emplace_back(st, PI);
    VP.emplace_back(-PI, en);
  } else
    VP.emplace_back(st, en);
}
int main() {
  int n;
  DB d;
  scanf("%d%lf", &n, &d);
  angles.push_back(-PI);
  angles.push_back(PI);
  for (int i = 0; i < n; i++) {
    p[i].in();
    scanf("%lf", &r[i]);
    DB dist = p[i].dis();
    DB from = dist - r[i], to = dist + r[i];
    int f = floor(from / d), t = ceil(to / d);
    for (int j = f; j <= t; j++) {
      PT tmp[2];
      if (posCirCir(PT(0, 0), 1.0 * d * j, p[i], r[i], tmp)) {
        DB st = getAngle(tmp[0]);
        DB en = getAngle(tmp[1]);
        insert(st, en);
      }
    }
  }
  sort(angles.begin(), angles.end());
  angles.erase(unique(angles.begin(), angles.end(), eq), angles.end());
  vi.resize(angles.size() + 2);
  for (auto &t : VP) {
    int from = lower_bound(angles.begin(), angles.end(), t.first - eps) -
               angles.begin();
    int to = lower_bound(angles.begin(), angles.end(), t.second - eps) -
             angles.begin();
    vi[from]++;
    vi[to + 1]--;
  }
  int cur = 0;
  int ans = 0;
  for (int i : vi) {
    cur += i;
    ans = max(ans, cur);
  }
  cout << ans << endl;
  return 0;
}
