A coder cannot sit and code all day. Sometimes it is a good idea to rise from the desk, have a rest, have small talk with colleagues and even play. The coders of the F company have their favorite ball game.

Let's imagine the game on the plane with a cartesian coordinate system. The point (0, 0) contains the player who chooses an arbitrary direction and throws a ball in that direction. The ball hits the plane at distance d from the player's original position and continues flying in the same direction. After the ball hits the plane for the first time, it flies on and hits the plane again at distance 2·d from the player's original position and so on (it continue flying in the chosen direction and hitting the plane after each d units). All coders in the F company are strong, so the ball flies infinitely far away.

The plane has n circles painted on it. If a ball hits the plane and hits a circle that is painted on the plane (including its border), then the player gets one point. The ball can hit multiple circles at once and get one point for each of them (if the ball hits some circle x times during the move, the player also gets x points). Count the maximum number of points a player can get if he throws a ball in the arbitrary direction. Note that the direction may have real cooridinates.

Input

The first line contains two space-separated integers — n и d (1 ≤ n ≤ 2·104; 5 ≤ d ≤ 10). Next n lines contain the circles' description. The i-th line contains three space-separated integers xi, yi, ri ( - 10000 ≤ xi, yi ≤ 10000; 1 ≤ r ≤ 50), where (xi, yi, ri) are the coordinates of the center and the radius of the circle, correspondingly. The point (0, 0) is not inside or on the border of some circle.

Output

Print a single integer — the maximum number of points you can get.

Examples

Input

2 5
1 1 1
5 0 1


Output

1


Input

2 5
4 0 3
5 3 1


Output

2


Input

1 10
20 0 10


Output

3
#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const long double PI = acos(-1);
inline int sign(long double a) { return (a < -EPS) ? -1 : ((a > EPS) ? 1 : 0); }
struct point {
  long double x, y;
  point(long double _x = 0.0, long double _y = 0.0) : x(_x), y(_y) {}
  point operator+(const point &a) const { return point(x + a.x, y + a.y); }
  point operator-(const point &a) const { return point(x - a.x, y - a.y); }
  point operator*(long double k) const { return point(x * k, y * k); }
  point operator/(long double k) const { return point(x / k, y / k); }
  long double operator*(const point &a) const { return x * a.x + y * a.y; }
  long double operator^(const point &a) const { return x * a.y - y * a.x; }
  bool operator==(const point &X) const { return x == X.x && y == X.y; }
  bool operator!=(const point &X) const { return !(*this == X); }
  bool operator<(const point &X) const { return x == X.x ? y < X.y : x < X.x; }
  point rotate(long double angle) {
    long double cosa = cos(angle), sina = sin(angle);
    return point(x * cosa - y * sina, x * sina + y * cosa);
  }
  long double norm() { return x * x + y * y; };
  long double len() { return sqrt(norm()); };
  long double angle() {
    long double res = atan2(y, x);
    if (res < 0) res = PI * 2 + res;
    return res;
  };
};
struct circle : point {
  long double r;
  circle(long double _x = 0, long double _y = 0, long double _r = 0)
      : point(_x, _y), r(_r) {}
  circle(point p, long double _r = 0) : point(p), r(_r) {}
};
struct line {
  long double a, b, c;
  point u, v;
  line(long double aa = 0.0, long double bb = 0.0, long double cc = 0.0)
      : a(aa), b(bb), c(cc) {}
  line(point _u, point _v) : u(_u), v(_v) {
    a = v.y - u.y;
    b = u.x - v.x;
    c = -(a * u.x + b * v.y);
  }
  line(point P, long double m) {
    a = -m;
    b = 1;
    c = -((a * P.x) + (b * P.y));
  }
  long double f(const point &p) { return a * p.x + b * p.y + c; }
};
long double angle(point a, point o, point b) {
  return acos(((a - o) * (b - o)) / (a - o).len() / (b - o).len());
};
long double directedAngle(point a, point o, point b) {
  long double t = -(a - o).angle() + (b - o).angle();
  while (t < 0) t += PI * 2;
  while (t >= PI * 2) t -= PI * 2;
  return t;
}
namespace geometry {
bool areParallel(line l1, line l2) {
  return sign(l1.a * l2.b == l1.b * l2.a) == 0;
}
bool areSame(line l1, line l2) {
  return areParallel(l1, l2) && sign(l1.c * l2.a - l2.c * l1.a) == 0 &&
         sign(l1.c * l2.b - l1.b * l2.c) == 0;
}
bool areIntersect(line l1, line l2, point &p) {
  if (areParallel(l1, l2)) return false;
  long double dx = l1.b * l2.c - l2.b * l1.c;
  long double dy = l1.c * l2.a - l2.c * l1.a;
  long double d = l1.a * l2.b - l2.a * l1.b;
  p = point(dx, dy) / d;
  return true;
}
void closestPoint(line l, point p, point &ans) {
  if (fabs(l.b) < EPS) {
    ans.x = -(l.c) / l.a;
    ans.y = p.y;
    return;
  }
  if (fabs(l.a) < EPS) {
    ans.x = p.x;
    ans.y = -(l.c) / l.b;
    return;
  }
  line perp(l.b, -l.a, -(l.b * p.x - l.a * p.y));
  areIntersect(l, perp, ans);
}
void reflectionPoint(line l, point p, point &ans) {
  point b;
  closestPoint(l, p, b);
  ans = p + (b - p) * 2;
}
circle getCircumcircle(point a, point b, point c) {
  long double d =
      2.0 * (a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y));
  assert(fabs(d) > EPS);
  long double x = (a.norm() * (b.y - c.y) + b.norm() * (c.y - a.y) +
                   c.norm() * (a.y - b.y)) /
                  d;
  long double y = (a.norm() * (c.x - b.x) + b.norm() * (a.x - c.x) +
                   c.norm() * (b.x - a.x)) /
                  d;
  point p(x, y);
  return circle(p, (p - a).len());
}
bool areIntersect(circle u, circle v) {
  if (sign((u - v).len() - (u.r + v.r)) > 0) return false;
  if (sign((u - v).len() + v.r - u.r) < 0) return false;
  if (sign((u - v).len() + u.r - v.r) < 0) return false;
  return true;
}
vector<point> circleIntersect(circle u, circle v) {
  vector<point> res;
  if (!areIntersect(u, v)) return res;
  long double d = (u - v).len();
  long double alpha = acos((u.r * u.r + d * d - v.r * v.r) / 2.0 / u.r / d);
  point p1 = (v - u).rotate(alpha);
  point p2 = (v - u).rotate(-alpha);
  res.push_back(p1 / p1.len() * u.r + u);
  res.push_back(p2 / p2.len() * u.r + u);
  return res;
}
}  // namespace geometry
int n, d;
circle a[20006];
int main() {
  iostream::sync_with_stdio(0);
  cin >> n >> d;
  vector<pair<long double, int> > ls;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].y >> a[i].r;
    int start = round(a[i].len());
    start = start - start % d;
    start -= d * (60 / d);
    for (int gap = max(0, start); gap <= start + d * (60 / d) * 2; gap += d) {
      if (geometry::areIntersect(circle(0, 0, gap), a[i])) {
        vector<point> ahi = geometry::circleIntersect(circle(0, 0, gap), a[i]);
        swap(ahi[0], ahi[1]);
        ls.push_back({ahi[0].angle(), 1});
        ls.push_back({ahi[1].angle() + EPS, -1});
        if (ahi[0].angle() > ahi[1].angle()) {
          ls.push_back({0, 1});
        }
      }
    }
  }
  sort(ls.begin(), ls.end());
  int cur = 0, ans = 0;
  for (auto v : ls) {
    cur += v.second;
    ans = max(ans, cur);
  }
  cout << ans;
}
