#include <bits/stdc++.h>
using namespace std;
static const double PI = acos(-1);
double Law_of_consines(double a, double b, double c) {
  return acos((b * b + c * c - a * a) / (2.0 * b * c));
}
class Point {
 public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(x * a, y * a); }
  Point operator/(double a) { return Point(x / a, y / a); }
  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  void rotate(double s, Point g = Point(0.0, 0.0)) {
    x = x - g.x;
    y = y - g.y;
    double nx = x * cos(s) - y * sin(s);
    double ny = x * sin(s) + y * cos(s);
    x = nx + g.x;
    y = ny + g.y;
  }
  bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const Point &p) const {
    return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
  }
};
double norm(Point a) { return a.x * a.x + a.y * a.y; }
double abs(Point a) { return sqrt(norm(a)); }
Point polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); }
double getDistance(Point a, Point b) { return abs(a - b); }
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
Point rotate(Point point, double s, Point g = Point(0.0, 0.0)) {
  point.x = point.x - g.x;
  point.y = point.y - g.y;
  double nx = point.x * cos(s) - point.y * sin(s);
  double ny = point.x * sin(s) + point.y * cos(s);
  point.x = nx + g.x;
  point.y = ny + g.y;
  return point;
}
class Circle {
 public:
  Point o;
  double r;
  Circle(Point o = Point(0.0, 0.0), double r = 0.0) : o(o), r(r) {}
  double area() { return r * r * PI; }
};
int getCrossStateCC(Circle a, Circle b) {
  double x = getDistance(a.o, b.o);
  if (x + b.r < a.r)
    return 2;
  else if (x + a.r < b.r)
    return -2;
  else if (x <= a.r + b.r)
    return 1;
  else
    return 0;
}
class Segment {
 public:
  Point p1, p2;
  Segment(Point p1 = Point(0.0, 0.0), Point p2 = Point(0.0, 0.0))
      : p1(p1), p2(p2) {}
  double abs() { return sqrt(norm()); }
  double norm() {
    return (p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y);
  }
};
Point project(Segment s, Point p) {
  Point base = s.p2 - s.p1;
  double t = dot(p - s.p1, base) / norm(base);
  return s.p1 + base * t;
}
Point reflect(Segment s, Point p) { return p + (project(s, p) - p) * 2.0; }
double getDistanceLP(Segment s, Point p) {
  return abs(cross(s.p2 - s.p1, p - s.p1) / abs(s.p2 - s.p1));
}
double getDistanceSP(Segment s, Point p) {
  if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1);
  if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2);
  return getDistanceLP(s, p);
}
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(Point p0, Point p1, Point p2) {
  Point a = p1 - p0;
  Point b = p2 - p0;
  if (cross(a, b) > (1e-10)) return COUNTER_CLOCKWISE;
  if (cross(a, b) < -(1e-10)) return CLOCKWISE;
  if (dot(a, b) < -(1e-10)) return ONLINE_BACK;
  if (norm(a) < norm(b)) return ONLINE_FRONT;
  return ON_SEGMENT;
}
bool inCircle(Circle cir, Point p) {
  double n = getDistance(cir.o, p);
  return (n < cir.r);
}
vector<Point> getCrossPoints(Circle cir1, Circle cir2) {
  vector<Point> res;
  if (getCrossStateCC(cir1, cir2) != 1) return res;
  Point A = cir1.o, B = cir2.o;
  double a = cir2.r, b = cir1.r;
  double c = getDistance(A, B);
  double n = Law_of_consines(a, b, c);
  Point AB = (B - A);
  Point AC = rotate(AB, n) / c * b;
  Point C = A + AC;
  res.push_back(C);
  Point C2 = reflect(Segment(A, B), C);
  if (!(C == C2)) res.push_back(C2);
  return res;
}
vector<Point> getCrossPointsCL(Circle cir, Segment line) {
  Point A = cir.o;
  Point B = reflect(line, A);
  Circle cirA = Circle(A, cir.r);
  Circle cirB = Circle(B, cir.r);
  return getCrossPoints(cirA, cirB);
}
vector<Point> getCrossPointsCS(Circle cir, Segment seg) {
  vector<Point> res, tmp;
  tmp = getCrossPointsCL(cir, seg);
  for (int i = 0; i < (int)tmp.size(); i++) {
    if (ccw(seg.p1, seg.p2, tmp[i]) == ON_SEGMENT) res.push_back(tmp[i]);
  }
  return res;
}
vector<Segment> getTangentialLine(Circle cir, Point p) {
  vector<Segment> res;
  Point O = cir.o, A = p, B, C;
  double n = getDistance(O, A);
  double m = sqrt(n * n - cir.r * cir.r);
  vector<Point> tmp = getCrossPoints(cir, Circle(A, m));
  for (int i = 0; i < (int)tmp.size(); i++) res.push_back(Segment(A, tmp[i]));
  return res;
}
Point getCrossPointLL(Segment l1, Segment l2) {
  double x1 = l1.p1.x, x2 = l1.p2.x, x3 = l2.p1.x, x4 = l2.p2.x;
  double y1 = l1.p1.y, y2 = l1.p2.y, y3 = l2.p1.y, y4 = l2.p2.y;
  double a1 = (y2 - y1) / (x2 - x1);
  double a3 = (y4 - y3) / (x4 - x3);
  double x = (a1 * x1 - y1 - a3 * x3 + y3) / (a1 - a3);
  double y = (y2 - y1) / (x2 - x1) * (x - x1) + y1;
  return Point(x, y);
}
int N, D;
Circle t[5];
Point start = Point(25.0, 0.0);
Point goal = Point(25.0, 94.0);
double ans;
double compute(int, int);
int check(Point);
int count(Segment);
int main() {
  while (cin >> N >> D && N) {
    ans = 999.999;
    for (int i = 0; i < N; i++) cin >> t[i].o.x >> t[i].o.y >> t[i].r;
    if (count(Segment(start, goal)) <= D) ans = 94.0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        ans = min(ans, compute(i, j));
      }
    }
    if (ans != 999.999)
      printf("%.8f\n", ans);
    else
      cout << "-1" << endl;
  }
  return 0;
}
double compute(int n, int m) {
  double res = 999.999;
  Point G;
  Segment seg1, seg2;
  int cnt;
  vector<Segment> A = getTangentialLine(t[n], start);
  vector<Segment> B = getTangentialLine(t[m], goal);
  for (int i = 0; i < (int)A.size(); i++) {
    for (int j = 0; j < (int)B.size(); j++) {
      G = getCrossPointLL(A[i], B[j]);
      if (G.x < 0.0 || G.x > 50.0 || G.y < 0.0 || G.y > 90.0) continue;
      seg1 = Segment(start, G);
      seg2 = Segment(G, goal);
      cnt = check(G);
      cnt += count(seg1);
      cnt += count(seg2);
      if (cnt <= D) {
        if (res > getDistance(start, G) + getDistance(G, goal)) {
          res = getDistance(start, G) + getDistance(G, goal);
        }
      }
    }
  }
  return res;
}
int count(Segment seg) {
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (getDistanceSP(seg, t[i].o) < t[i].r - (1e-10)) res++;
  }
  return res;
}
int check(Point p) {
  for (int i = 0; i < N; i++) {
    if (getDistance(p, t[i].o) < t[i].r) return -1;
  }
  return 0;
}
