#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7, pi = 3.1415926535897932384626;
inline int getnum() {
  int ans = 0, fh = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh *= -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ans = ans * 10 + ch - '0', ch = getchar();
  return fh * ans;
}
inline double angabs(double angle) {
  while (angle + eps > 2 * pi) angle -= 2 * pi;
  while (angle < -eps) angle += 2 * pi;
  return angle;
}
int n;
double d;
struct point {
  double x, y;
  point(double X = 0, double Y = 0) { x = X, y = Y; }
};
inline double dis2(point a, point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
inline double dis(point a, point b) { return sqrt(dis2(a, b)); }
struct circle {
  point o;
  double r;
} c[210000];
struct T {
  double a;
  int tmp;
  friend bool operator<(T A, T B) {
    if (abs(A.a - B.a) < eps)
      return A.tmp > B.tmp;
    else
      return A.a + eps < B.a;
  }
} ang[2100000];
int anum;
int main(int argc, char *argv[]) {
  n = getnum(), d = getnum();
  for (int i = 1; i <= n; i++)
    c[i].o.x = getnum(), c[i].o.y = getnum(), c[i].r = getnum();
  for (int i = 1; i <= n; i++) {
    double odis = dis(point(0, 0), c[i].o);
    int near = (int)(ceil(abs(odis - c[i].r) / d) + eps),
        far = (int)(floor((odis + c[i].r) / d) + eps);
    for (int j = near; j <= far; j++) {
      double nowr = j * d;
      double ang1 = atan2(c[i].o.y, c[i].o.x);
      double ang2 = acos((nowr * nowr + odis * odis - c[i].r * c[i].r) /
                         (2 * nowr * odis));
      ang[++anum].a = angabs(ang1 - ang2);
      ang[anum].tmp = 1;
      ang[++anum].a = angabs(ang1 + ang2);
      ang[anum].tmp = -1;
      if (angabs(ang1 - ang2) > angabs(ang1 + ang2) + eps)
        ang[++anum].a = 0, ang[anum].tmp = 1;
    }
  }
  sort(ang + 1, ang + anum + 1);
  int sum = 0, ans = 0;
  for (int i = 1; i <= anum; i++) {
    sum += ang[i].tmp;
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
