#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
const double eps = 0.00000001;
struct pnt {
  double ang;
  int d;
} p[1000010];
double du(int x) { return x; }
bool equ(double x, double y) { return fabs(x - y) <= eps; }
bool cmp(pnt a, pnt b) {
  return equ(a.ang, b.ang) ? (a.d > b.d) : (a.ang < b.ang);
}
int main() {
  int n, d, i, j, x, y, r, cnt, sum, mx;
  double dis, a1, a2, s1, s2;
  scanf("%d%d", &n, &d);
  cnt = sum = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d", &x, &y, &r);
    dis = sqrt(x * x + y * y);
    a1 = atan2(y, x);
    for (j = ceil((dis - r) / du(d)); j <= floor((dis + r) / du(d)); j++) {
      a2 = acos((dis * dis + du(d * d * j * j - r * r)) / (2 * j * d * dis));
      s1 = a1 - a2;
      s2 = a1 + a2;
      if (s1 <= -pi) {
        s1 += 2 * pi;
        sum++;
      }
      if (s2 >= pi) {
        s2 -= 2 * pi;
        sum++;
      }
      cnt++;
      p[cnt].ang = s1;
      p[cnt].d = 1;
      cnt++;
      p[cnt].ang = s2;
      p[cnt].d = -1;
    }
  }
  sort(p + 1, p + cnt + 1, cmp);
  mx = 0;
  for (i = 1; i <= cnt; i++) {
    sum += p[i].d;
    mx = max(mx, sum);
  }
  printf("%d", mx);
}
