#include <bits/stdc++.h>
using namespace std;
const int inf = 0x20202020;
const long long mod = 1000000007;
const double eps = 1e-9;
const double pi = 3.1415926535897932384626;
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
vector<pair<double, int> > vec;
int cnt, n, d, x, y, r, ans;
void add(double l, double r) {
  while (l < 0) l += 2 * pi;
  while (l >= 2 * pi) l -= 2 * pi;
  while (r < 0) r += 2 * pi;
  while (r >= 2 * pi) r -= 2 * pi;
  vec.push_back(make_pair(l, -1));
  vec.push_back(make_pair(r, 1));
  if (l > r) cnt++;
}
int main() {
  scanf("%d%d", &n, &d);
  for (int i = 0; i < (int)n; i++) {
    scanf("%d%d%d", &x, &y, &r);
    double dis = sqrt(x * x + y * y);
    int cl = ceil(max((dis - r) / d, 1.)), cr = floor((dis + r) / d);
    double th = atan2(y, x);
    for (int j = cl; j < (int)cr + 1; j++) {
      double th2 = acos((j * j * d * d + dis * dis - r * r) / 2 / j / d / dis);
      add(th - th2, th + th2);
    }
  }
  sort((vec).begin(), (vec).end());
  ans = cnt;
  for (int i = 0; i < (int)((int)(vec).size()); i++)
    ans = max(ans, (cnt -= vec[i].second));
  printf("%d\n", ans);
}
