#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native")
using namespace std;
namespace output {
void __(short x) { cout << x; }
void __(unsigned x) { cout << x; }
void __(int x) { cout << x; }
void __(long long x) { cout << x; }
void __(unsigned long long x) { cout << x; }
void __(double x) { cout << x; }
void __(long double x) { cout << x; }
void __(char x) { cout << x; }
void __(const char* x) { cout << x; }
void __(const string& x) { cout << x; }
void __(bool x) { cout << (x ? "true" : "false"); }
template <class S, class T>
void __(const pair<S, T>& x) {
  __(1 ? "(" : ""), __(x.first), __(1 ? ", " : " "), __(x.second),
      __(1 ? ")" : "");
}
template <class T>
void __(const vector<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class T>
void __(const set<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class T>
void __(const multiset<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class S, class T>
void __(const map<S, T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
void pr() { cout << "\n"; }
template <class S, class... T>
void pr(const S& a, const T&... b) {
  __(a);
  if (sizeof...(b)) __(' ');
  pr(b...);
}
}  // namespace output
using namespace output;
const int MN = 2e4 + 5;
const double eps = 1e-7, PI = (double)acos((double)-1);
int N, D, i, j, x, y, r;
double ang, lo, hi, mid;
inline double dis(pair<int, int> x) {
  return sqrt(1LL * x.first * x.first + 1LL * x.second * x.second);
}
inline double dis(pair<double, double> x) {
  return sqrt(x.first * x.first + x.second * x.second);
}
pair<double, double> vec;
vector<pair<double, int>> go;
int main() {
  scanf("%d%d", &N, &D);
  for (i = 1; i <= N; i++) {
    scanf("%d%d%d", &x, &y, &r);
    double dd = dis(make_pair(x, y));
    int approx = dd / (double)D;
    ang = atan2(y, x);
    for (j = approx; j > 0; j--) {
      if (D * j + eps >= dd - r) {
        lo = ang - PI / 2, hi = ang;
        while (lo + eps < hi) {
          mid = (lo + hi) / 2;
          vec = {D * j * cos(mid), D * j * sin(mid)};
          if (dis(make_pair(vec.first - x, vec.second - y)) <= r)
            hi = mid;
          else
            lo = mid + eps;
        }
        double a = lo;
        if (a < 0) a += 2 * PI;
        if (a >= 2 * PI) a -= 2 * PI;
        lo = ang + eps, hi = ang + eps + PI / 2;
        while (lo + eps < hi) {
          mid = (lo + hi) / 2;
          vec = {D * j * cos(mid), D * j * sin(mid)};
          if (dis(make_pair(vec.first - x, vec.second - y)) <= r)
            lo = mid + eps;
          else
            hi = mid;
        }
        double b = lo;
        if (b < 0) b += 2 * PI;
        if (b >= 2 * PI) b -= 2 * PI;
        if (a < b) {
          go.push_back({a, 1});
          go.push_back({b, 0});
        } else {
          go.push_back({a, 1});
          go.push_back({0, 1});
          go.push_back({b, 0});
        }
      } else
        break;
    }
    for (j = approx + 1;; j++) {
      if (D * j - eps <= dd + r) {
        lo = ang - PI / 2, hi = ang;
        while (lo + eps < hi) {
          mid = (lo + hi) / 2;
          vec = {D * j * cos(mid), D * j * sin(mid)};
          if (dis(make_pair(vec.first - x, vec.second - y)) <= r)
            hi = mid;
          else
            lo = mid + eps;
        }
        double a = lo;
        if (a < 0) a += 2 * PI;
        if (a >= 2 * PI) a -= 2 * PI;
        lo = ang + eps, hi = ang + eps + PI / 2;
        while (lo + eps < hi) {
          mid = (lo + hi) / 2;
          vec = {D * j * cos(mid), D * j * sin(mid)};
          if (dis(make_pair(vec.first - x, vec.second - y)) <= r)
            lo = mid + eps;
          else
            hi = mid;
        }
        double b = lo;
        if (b < 0) b += 2 * PI;
        if (b >= 2 * PI) b -= 2 * PI;
        if (a < b) {
          go.push_back({a, 1});
          go.push_back({b, 0});
        } else {
          go.push_back({a, 1});
          go.push_back({0, 1});
          go.push_back({b, 0});
        }
      } else
        break;
    }
  }
  sort(go.begin(), go.end(), [](pair<double, int> i, pair<double, int> j) {
    return i.first < j.first;
  });
  int ans = 0, cur = 0;
  for (i = 0; i < (int)go.size(); i = j) {
    for (j = i; j < (int)go.size() && go[j].first == go[i].first; j++) {
      if (go[j].second)
        cur++;
      else
        cur--;
    }
    ans = max(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}
