#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
long double pi = acos(-1);
int X[N], Y[N], R[N];
void thik(long double &x) {
  if (x < -pi) x += 2.0 * pi;
  if (x >= pi) x -= 2.0 * pi;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, D;
  cin >> n >> D;
  vector<pair<long double, bool>> marks;
  int balance = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> X[i] >> Y[i] >> R[i];
    long long lhs = 1ll * X[i] * X[i] + 1ll * Y[i] * Y[i];
    int lo = 1, hi = 1e6;
    while (hi > lo) {
      int mid = (lo + hi) >> 1;
      long long rhs = 1ll * mid * D + R[i];
      rhs *= rhs;
      if (lhs <= rhs)
        hi = mid;
      else
        lo = mid + 1;
    }
    int low = lo;
    lo = low, hi = 1e6;
    while (hi > lo) {
      int mid = (lo + hi) >> 1;
      long long rhs = 1ll * mid * D - R[i];
      rhs *= rhs;
      if (lhs < rhs)
        hi = mid;
      else
        lo = mid + 1;
    }
    int high = lo;
    for (int k = low; k < high; k++) {
      long double ang = atan2(Y[i], X[i]);
      long double R2 = k * D;
      long double d = sqrtl(X[i] * X[i] + Y[i] * Y[i]);
      long double R1 = R[i];
      long double cos = (R2 * R2 + lhs - R1 * R1) / (2.0 * R2 * d);
      cos = max(-1.0l, cos);
      cos = min(1.0l, cos);
      long double dev = acos(cos);
      long double a = ang - dev;
      thik(a);
      long double b = ang + dev;
      thik(b);
      marks.push_back({a, 0});
      marks.push_back({b, 1});
      if (a > b) balance++;
    }
  }
  sort(marks.begin(), marks.end());
  ans = balance;
  for (auto t : marks) {
    if (t.second == 1)
      balance--;
    else
      balance++;
    ans = max(ans, balance);
  }
  cout << ans << endl;
  return 0;
}
