#include <bits/stdc++.h>
using namespace std;
struct circle {
  long double x, y, r;
};
struct mod {
  long double theta, op;
};
struct node {
  long double x, y, theta;
};
int n, d, i, j, tot, S, ans, gg;
circle c[20005];
mod l[2000005];
node A, B;
long double D, k, t, L, R, dis1, dis2, dis3;
void getAB() {
  long double x = c[i].x, y = c[i].y, r = c[i].r, delta;
  if (x == 0) {
    t = (r * r - x * x - y * y - D * D) / (-2 * y);
    k = -x / y;
    delta = (2 * t * k) * (2 * t * k) - 4 * (k * k + 1) * (t * t - D * D);
    if (delta < 0) {
      A.x = A.y = 0;
      return;
    }
    A.x = (-(2 * t * k) + sqrt(delta)) / (2 * (k * k + 1));
    B.x = (-(2 * t * k) - sqrt(delta)) / (2 * (k * k + 1));
    A.y = (r * r - x * x - y * y - D * D + 2 * x * A.x) / (-2 * y);
    B.y = (r * r - x * x - y * y - D * D + 2 * x * B.x) / (-2 * y);
  } else {
    t = (r * r - x * x - y * y - D * D) / (-2 * x);
    k = -y / x;
    delta = (2 * t * k) * (2 * t * k) - 4 * (k * k + 1) * (t * t - D * D);
    if (delta < 0) {
      A.x = A.y = 0;
      return;
    }
    A.y = (-(2 * t * k) + sqrt(delta)) / (2 * (k * k + 1));
    B.y = (-(2 * t * k) - sqrt(delta)) / (2 * (k * k + 1));
    A.x = (r * r - x * x - y * y - D * D + 2 * y * A.y) / (-2 * x);
    B.x = (r * r - x * x - y * y - D * D + 2 * y * B.y) / (-2 * x);
  }
}
void insert(long double L, long double R) {
  tot++;
  l[tot].theta = L;
  l[tot].op = 1;
  tot++;
  l[tot].theta = R + 0.0000000001;
  l[tot].op = -1;
}
int comp(mod A, mod B) {
  return ((A.theta < B.theta) || ((A.theta == B.theta) && (A.op < B.op)));
}
int main() {
  scanf("%d%d", &n, &d);
  for (i = 1; i <= n; i++) {
    scanf("%Lf%Lf%Lf", &c[i].x, &c[i].y, &c[i].r);
  }
  for (i = 1; i <= n; i++) {
    gg = sqrt(c[i].x * c[i].x + c[i].y * c[i].y) / d;
    for (D = (long double)max(gg - 100, 1) * (long double)d;
         D <= (long double)(gg + 100) * (long double)d; D += (long double)d) {
      getAB();
      if ((A.x == 0) && (A.y == 0)) continue;
      A.theta = atan2(A.x, A.y);
      B.theta = atan2(B.x, B.y);
      if (A.theta > B.theta) swap(A, B);
      L = A.theta;
      R = B.theta;
      if (R - L > 3.1415926535) swap(L, R);
      if (L <= R)
        insert(L, R);
      else
        insert(-3.1415926535, R), insert(L, 3.1415926535);
    }
  }
  sort(l + 1, l + 1 + tot, comp);
  for (i = 1; i <= tot; i++) {
    S += l[i].op;
    ans = max(ans, S);
  }
  printf("%d", ans);
}
