#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int MOD = 1000000007;
const double pi = acos(-1.0);
const long double EPS = 1e-9;
struct PP {
  long double ang;
  int delta;
  PP(long double _ang, int _delta) : ang(_ang), delta(_delta) {}
  bool operator<(PP other) const {
    return ang + EPS < other.ang ||
           abs(ang - other.ang) < EPS && delta < other.delta;
  }
};
long double angleTo(long double x, long double y, long double x1,
                    long double y1) {
  return atan2(y1 - y, x1 - x);
}
int main() {
  int n;
  double d;
  cin >> n >> d;
  vector<PP> g;
  for (int i = (0); i <= (n - 1); ++i) {
    long double x, y, r;
    cin >> x >> y >> r;
    long double D = sqrt(x * x + y * y);
    long double mx = D + r;
    long double mn = D - r;
    mn = d * int((mn - EPS) / d + 1);
    while (mn <= mx + EPS) {
      long double ang = angleTo(0, 0, x, y);
      long double f = acos((D * D + mn * mn - r * r) / (2 * D * mn));
      long double low = ang - f, high = ang + f;
      if (low < 0 && high < 0) low += 2 * pi, high += 2 * pi;
      if (low < 0) {
        g.push_back(PP(low + 2 * pi, -1));
        g.push_back(PP(2 * pi, 1));
        g.push_back(PP(0, -1));
        g.push_back(PP(high, 1));
      } else if (high > 2 * pi) {
        g.push_back(PP(low, -1));
        g.push_back(PP(2 * pi, 1));
        g.push_back(PP(0, -1));
        g.push_back(PP(high - 2 * pi, 1));
      } else {
        g.push_back(PP(low, -1));
        g.push_back(PP(high, 1));
      }
      mn += d;
    }
  }
  sort(g.begin(), g.end());
  int ans = 0;
  int cur = 0;
  for (int i = (0); i <= ((int)((g).size()) - 1); ++i) {
    cur -= g[i].delta;
    ans = max(ans, cur);
  }
  cout << ans << endl;
}
