#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 50;
const long double eps = 1e-10, pi = atan(1.0) * 4.0;
inline int sgn(long double x, long double y) {
  if (fabs(x - y) <= eps)
    return 0;
  else if (x - y > eps)
    return 1;
  else
    return -1;
}
struct Li {
  long double ang;
  int key, id;
  Li() {}
  Li(long double _ang, int _key, int _id) {
    ang = _ang;
    key = _key;
    id = _id;
  }
  friend bool operator<(const Li &A, const Li &B) {
    if (!sgn(A.ang, B.ang))
      return A.key < B.key;
    else
      return (sgn(A.ang, B.ang) < 0);
  }
} line[maxn * 40];
int n, tot, ti, vis[maxn * 40];
long double d;
struct BIT {
  int g[maxn * 40 + 50];
  void add(int x, int k) {
    for (; x <= tot; x += x & -x) g[x] += k;
  }
  int get(int x) {
    int res(0);
    for (; x; x -= x & -x) res += g[x];
    return res;
  }
} T;
int main() {
  cin >> n >> d;
  for (int i = 1; i <= n; ++i) {
    long double x, y, r;
    cin >> x >> y >> r;
    long double dis = sqrt(x * x + y * y), midis = dis - r, mxdis = dis + r;
    int id = (int)((midis - eps) / d);
    while (d * id + eps < midis) id++;
    while ((long double)d * id - eps < mxdis) {
      long double len = (long double)d * id;
      long double tmp =
          acos((dis * dis + len * len - r * r) / 2.0 / dis / len - eps);
      long double la = atan2(y, x), ra = la + tmp;
      la -= tmp;
      if (sgn(la, -pi) < 0) la += pi * 2.0;
      if (sgn(ra, pi) > 0) ra -= pi * 2.0;
      if (sgn(la, ra) < 0) {
        line[++tot] = Li(la, 1, ++ti);
        line[++tot] = Li(ra, -1, ti);
      } else {
        line[++tot] = Li(-pi, 1, ++ti);
        line[++tot] = Li(ra, -1, ti);
        line[++tot] = Li(la, 1, ++ti);
        line[++tot] = Li(pi, -1, ti);
      }
      ++id;
    }
  }
  sort(line + 1, line + 1 + tot);
  int ans(0);
  for (int i = 1; i <= tot; ++i) {
    if (!vis[line[i].id]) {
      vis[line[i].id] = i;
      T.add(i, 1);
    } else {
      ans = max(ans, T.get(i));
      T.add(i, -1);
    }
  }
  printf("%d\n", ans);
  return 0;
}
