#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void mine(T1 &x, const T2 &y) {
  if (y < x) x = y;
}
template <typename T1, typename T2>
inline void maxe(T1 &x, const T2 &y) {
  if (x < y) x = y;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &b) {
  for (auto &k : b) os << k << ' ';
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &b) {
  for (auto &k : b) is >> k;
  return is;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long double EPS = 1e-9;
const long double PI = 4 * atan(1);
long long sq(long long x) { return x * x; }
long double fix(long double a) {
  if (a < 0) a += 2 * PI;
  if (a >= 2 * PI) a -= 2 * PI;
  return a;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, d;
  cin >> n >> d;
  vector<pair<long double, long long>> scan;
  for (long long i = 0; i < n; ++i) {
    long long x, y, r;
    cin >> x >> y >> r;
    ;
    long long d2 = x * x + y * y;
    long long L = 0;
    long long R = 4000;
    while (R - L > 1) {
      long long mid = (L + R) / 2;
      if (sq(mid * d + r) >= d2)
        R = mid;
      else
        L = mid;
    }
    long double ang = fix(atan2(y, x));
    for (R *= d; R < r || sq(R - r) <= d2; R += d) {
      ;
      ;
      ;
      ;
      ;
      long double cosdelta = (d2 + sq(R) - sq(r)) / (2 * sqrt(d2) * R);
      ;
      ;
      long double delta = acos(cosdelta) + EPS;
      assert(delta > 0);
      long double leftkekmda = fix(ang - delta);
      long double rightkekmda = fix(ang + delta);
      if (leftkekmda > rightkekmda) {
        scan.push_back({0, 1});
      }
      scan.push_back({leftkekmda, 1});
      scan.push_back({rightkekmda, -1});
    }
  }
  sort(scan.begin(), scan.end());
  long long ans = 0;
  long long bal = 0;
  for (auto &x : scan) {
    bal += x.second;
    maxe(ans, bal);
  }
  cout << ans << '\n';
}
