#include <bits/stdc++.h>
using namespace std;
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 k) { return Point(x * k, y * k); }
  Point operator/(double k) { return Point(x / k, y / k); }
  bool operator<(Point p) const { return (x != p.x ? x < p.x : y < p.y); }
  bool operator==(Point p) const {
    return fabs(x - p.x) < (1e-6) && fabs(y - p.y) < (1e-6);
  }
  double abs() { return sqrt(norm()); }
  double norm() { return (x * x + y * y); }
};
class Segment {
 public:
  Point p1, p2;
  Segment(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}
};
class Circle {
 public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
};
double norm(Point a) { return (a.x * a.x + a.y * a.y); }
double abs(Point a) { return sqrt(norm(a)); }
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); }
double getDistanceLP(Segment l, Point p) {
  return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}
double getDistanceSP(Segment second, Point p) {
  if (dot(second.p2 - second.p1, p - second.p1) < 0.0)
    return abs(p - second.p1);
  if (dot(second.p1 - second.p2, p - second.p2) < 0.0)
    return abs(p - second.p2);
  return getDistanceLP(second, p);
}
bool intersect(Circle c, Segment second) {
  if (getDistanceSP(second, c.c) - c.r < -(1e-6)) return true;
  return false;
}
Point getCrossPointLL(Segment a, Segment b) {
  double A = cross(a.p2 - a.p1, b.p2 - b.p1);
  double B = cross(a.p2 - a.p1, a.p2 - b.p1);
  if (abs(A) < (1e-6) || abs(B) < (1e-6)) return b.p1;
  return b.p1 + (b.p2 - b.p1) * (B / A);
}
Point rotate(Point base, Point a, double r) {
  Point b = a - base;
  a.x = b.x * cos((r / 180) * M_PI) - b.y * sin((r / 180) * M_PI);
  a.y = b.x * sin((r / 180) * M_PI) + b.y * cos((r / 180) * M_PI);
  a = a + base;
  return a;
}
pair<Point, Point> getTangent(Circle c, Point p) {
  Point v = p - c.c;
  double r = acos(c.r / abs(v)) * 360 / (2 * M_PI);
  v = v * c.r / abs(v);
  Point p1 = rotate(c.c, c.c + v, r);
  Point p2 = rotate(c.c, c.c + v, 360 - r);
  return make_pair(p1, p2);
}
int n, d, x, y, r;
vector<Circle> vc;
Point second(25, 0), g(25, 94);
double ans = 1 << 30;
bool in(Point p) {
  if (p.x - 0 < -(1e-6) || 50 - p.x < -(1e-6)) return false;
  if (p.y - 0 < -(1e-6) || 94 - p.y < -(1e-6)) return false;
  return true;
}
bool check(Point p) {
  set<int> st;
  Segment s1(second, p), s2(p, g);
  for (int i = 0; i < vc.size(); i++) {
    if (intersect(vc[i], s1)) st.insert(i);
    if (intersect(vc[i], s2)) st.insert(i);
  }
  if (st.size() <= d) return true;
  return false;
}
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> r;
    vc.push_back(Circle(Point(x, y), r));
  }
  vector<Segment> vs, vg;
  for (int i = 0; i < n; i++) {
    pair<Point, Point> pp = getTangent(vc[i], second);
    vs.push_back(Segment(second, pp.first));
    vs.push_back(Segment(second, pp.second));
    pp = getTangent(vc[i], g);
    vg.push_back(Segment(g, pp.first));
    vg.push_back(Segment(g, pp.second));
  }
  if (check(Point(25, 47))) ans = abs(g - second);
  for (int i = 0; i < vs.size(); i++) {
    for (int j = 0; j < vg.size(); j++) {
      Point p = getCrossPointLL(vs[i], vg[j]);
      if (!in(p)) continue;
      if (check(p)) ans = min(ans, abs(second - p) + abs(g - p));
    }
  }
  if (ans == 1 << 30)
    cout << -1;
  else
    printf("%.10f", ans);
  cout << endl;
  return 0;
}
