#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<double, int> > vec;
  int n, d;
  scanf("%d %d", &n, &d);
  while (n--) {
    int x, y, r;
    scanf("%d %d %d", &x, &y, &r);
    int R2 = x * x + y * y;
    double R = sqrt(R2);
    double L = (int)(R - r) / d * d;
    if (L < R - r - 1e-8) L += d;
    double angle = atan2(y, x);
    for (; L < R + r + 1e-8; L += d) {
      double delta = acos((R2 + L * L - r * r) / 2 / R / L);
      vec.push_back(pair<double, int>(angle - delta, 1));
      vec.push_back(pair<double, int>(angle + delta + 1e-8, -1));
    }
  }
  sort(vec.begin(), vec.end());
  int sum = 0, ans = 0;
  for (pair<double, int> p : vec) {
    sum += p.second;
    if (sum > ans) ans = sum;
  }
  printf("%d", ans);
}
