#include <bits/stdc++.h>
using namespace std;
const long double pi = 4 * atan(1);
const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const long double EPS = 1e-9;
int cmp(long double x, long double y = 0, long double tol = EPS) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
int main() {
  int n, d;
  scanf("%d %d", &n, &d);
  vector<pair<long double, int>> events;
  int init = 0;
  for (decltype(0) i = (0); i < (n); ++i) {
    int x, y, r;
    scanf("%d %d %d", &x, &y, &r);
    long double R = r;
    long double D = hypotl(y, x);
    long double theta = atan2l(y, x);
    int md = (int)ceill((D - R) / d - EPS);
    int Md = (int)floorl((D + R) / d + EPS);
    if (md > Md) continue;
    for (decltype(md) j = (md); j < (Md + 1); ++j) {
      long double theta2 =
          acosl((D * D + d * j * d * j - R * R) / (2. * D * d * j));
      auto f = [](long double x) -> long double {
        while (x < 0) x += 2 * pi;
        while (x > 2 * pi) x -= 2 * pi;
        return x;
      };
      long double theta3 = f(theta - theta2);
      long double theta4 = f(theta + theta2);
      if (theta3 > theta4 || theta3 == 0) init++;
      events.emplace_back(theta3, -1);
      events.emplace_back(theta4, +1);
    }
  }
  sort((events).begin(), (events).end());
  int ans = init;
  for (auto &x : events)
    if (x.first > 0.) {
      init -= x.second;
      ans = max(ans, init);
    }
  printf("%d\n", ans);
  return 0;
}
