#include <bits/stdc++.h>
using namespace std;
const int maxn = 1640005;
struct pi {
  int x, y, r;
} pp[maxn / 20];
double dis(int x1, int y1) {
  double xx = x1;
  double yy = y1;
  return sqrt(xx * xx + yy * yy);
}
struct ppi {
  double y;
  int id;
} p1[maxn];
int be(double x, double y) {
  if (x > y) return 1;
  if (fabs(x - y) < 1e-8) return 1;
  return 0;
}
int se(double y, double x) {
  if (x > y) return 1;
  if (fabs(x - y) < 1e-8) return 1;
  return 0;
}
int cmp(ppi a, ppi b) {
  if (a.y != b.y) return a.y < b.y;
  return a.id > b.id;
}
int cnt;
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &pp[i].x, &pp[i].y, &pp[i].r);
  for (int i = 1; i <= n; i++) {
    double x = dis(pp[i].x, pp[i].y);
    int w = (x - pp[i].r - 1e-8);
    w = w / d;
    double ord;
    if (pp[i].x == 0) {
      if (pp[i].y > 0)
        ord = 3.141592653589793 / 2;
      else
        ord = 3.141592653589793 * 3 / 2;
    } else {
      ord = atan((1.0 * pp[i].y) / (pp[i].x));
      if (ord > 0) {
        if (pp[i].y < 0) {
          ord += 3.141592653589793;
        }
      } else if (ord < 0) {
        if (pp[i].y > 0) {
          ord += 3.141592653589793;
        } else
          ord += 2 * 3.141592653589793;
      } else {
        if (pp[i].x < 0) ord = 3.141592653589793;
      }
    }
    for (int j = w; d * j <= x + pp[i].r + 1e-8; j++) {
      if (j * d >= x - pp[i].r) {
        if (fabs(x - pp[i].r - j * d) < 1e-8 ||
            fabs(x + pp[i].r - j * d) < 1e-8) {
          p1[cnt].y = ord;
          p1[cnt++].id = 1;
          p1[cnt].y = ord;
          p1[cnt++].id = -1;
          continue;
        }
        double xi = acos((x * x + 1.0 * j * d * j * d - pp[i].r * pp[i].r) /
                         (2 * x * j * d));
        if (ord + xi > 2 * 3.141592653589793) {
          p1[cnt].y = 0;
          p1[cnt++].id = 1;
          p1[cnt].y = ord + xi - 2 * 3.141592653589793;
          p1[cnt++].id = -1;
          p1[cnt].y = ord;
          p1[cnt++].id = 1;
          p1[cnt].y = 2 * 3.141592653589793;
          p1[cnt++].id = -1;
        } else {
          p1[cnt].y = ord;
          p1[cnt++].id = 1;
          p1[cnt].y = ord + xi;
          p1[cnt++].id = -1;
        }
        if (ord - xi < 0) {
          if (fabs(ord) < 1e-8) {
            p1[cnt].y = 2 * 3.141592653589793 - xi;
            p1[cnt++].id = 1;
            p1[cnt].y = 2 * 3.141592653589793;
            p1[cnt++].id = -1;
            continue;
          }
          p1[cnt].y = 0;
          p1[cnt++].id = 1;
          p1[cnt].y = ord - 1e-8;
          p1[cnt++].id = -1;
          p1[cnt].y = 2 * 3.141592653589793 + ord - xi;
          p1[cnt++].id = 1;
          p1[cnt].y = 2 * 3.141592653589793;
          p1[cnt++].id = -1;
        } else {
          p1[cnt].y = ord - xi;
          p1[cnt++].id = 1;
          p1[cnt].y = ord - 1e-8;
          p1[cnt++].id = -1;
        }
      }
    }
  }
  sort(p1, p1 + cnt, cmp);
  int ma = 0;
  int no = 0;
  for (int i = 0; i < cnt; i++) {
    no += p1[i].id;
    ma = max(ma, no);
  }
  cout << ma << endl;
}
