#include <bits/stdc++.h>
using namespace std;
const long double e = 1e-12;
long double pi = asin(1) * 2;
vector<pair<long double, int> > sobs;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  long double d;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    long double x, y, r;
    cin >> x >> y >> r;
    long double dd = sqrtf(x * x + y * y);
    long double mnr = dd - r, mxr = dd + r;
    int id = (int)((mnr - e) / d);
    while (d * id + e < mnr) id++;
    long double mang = -e;
    while (d * (long double)id < mxr + e) {
      long double aa = r, bb = d * (long double)id, cc = dd;
      mang = acos((bb * bb + cc * cc - aa * aa) / 2.0 / bb / cc - e);
      long double ml = atan2(y, x);
      long double mr = ml + mang;
      ml -= mang;
      if (ml < -pi) ml += 2 * pi;
      if (mr > pi) mr -= 2 * pi;
      sobs.push_back(make_pair(ml, 1));
      sobs.push_back(make_pair(mr, -1));
      if (ml > mr) {
        sobs.push_back(make_pair(-pi, 1));
        sobs.push_back(make_pair(pi, -1));
      }
      id++;
    }
  }
  sort(sobs.begin(), sobs.end());
  int cn = 0, rs = 0, minu = 0;
  for (int i = 0; i < (int)sobs.size(); i++) {
    if (sobs[i].second == -1)
      ++minu;
    else {
      ++cn;
      if (!i || abs(sobs[i].first - sobs[i - 1].first) > 1e-9) {
        cn -= minu;
        minu = 0;
      }
    }
    rs = max(rs, cn);
  }
  cout << rs << endl;
  return 0;
}
