#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-8;
const double PI = acos(-1);
complex<double> pIN() {
  double x, y;
  cin >> x >> y;
  return complex<double>(x, y);
}
namespace std {
bool operator<(const complex<double> &a, const complex<double> &b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}  // namespace std
double cross(const complex<double> &a, const complex<double> &b) {
  return imag(conj(a) * b);
}
double dot(const complex<double> &a, const complex<double> &b) {
  return real(conj(a) * b);
}
struct L : public vector<complex<double> > {
  L(const complex<double> &a, const complex<double> &b) {
    push_back(a);
    push_back(b);
  }
  L() { resize(2); }
};
ostream &operator<<(ostream &os, const L &a) {
  os << a[0] << " -> " << a[1];
  return os;
}
struct C {
  complex<double> p;
  double r;
  C() {}
  C(const complex<double> &p, double r) : p(p), r(r) {}
};
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > EPS) return +1;
  if (cross(b, c) < -EPS) return -1;
  if (dot(b, c) < -EPS) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1] - l[0], m[1] - m[0])) > EPS ||
         abs(cross(l[1] - l[0], m[0] - l[0])) < EPS;
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1] - l[0], s[0] - l[0]) * cross(l[1] - l[0], s[1] - l[0]) <
         EPS;
}
bool intersectLP(const L &l, const complex<double> &p) {
  return abs(cross(l[1] - p, l[0] - p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
         ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
bool intersectSS2(const L &s, const L &t) {
  for (int i = 0; i < (int)(2); ++i) {
    if (ccw(s[0], s[1], t[i]) == 0) {
      int c = ccw(s[0], s[1], t[!i]);
      if (s[0] == t[i]) {
        if (c != -2 && c) return 0;
      } else if (s[1] == t[i]) {
        if (c != 2 && c) return 0;
      } else if (abs(c) == 1)
        return 0;
    }
  }
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
         ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
bool intersectSP(const L &s, const complex<double> &p) {
  return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS;
}
bool intersectLH(const L &l, const L &h) {
  if (intersectLS(l, h)) return 1;
  if (!intersectLL(l, h)) return 0;
  if (abs(cross(l[1] - l[0], h[1] - h[0])) < EPS) return 1;
  return (ccw(l[0], l[1], h[0]) == 1) ^ (cross(l[1] - l[0], h[1] - h[0]) > 0);
}
bool intersectHS(const L &h, const L &s) {
  if (intersectSS(h, s)) return 1;
  if (!intersectLS(h, s)) return 0;
  if (abs(cross(s[1] - s[0], h[1] - h[0])) < EPS)
    return ccw(h[0], h[1], s[0]) != 2 || ccw(h[0], h[1], s[1]) != 2;
  return (ccw(s[0], s[1], h[0]) == 1) ^ (cross(s[1] - s[0], h[1] - h[0]) > 0);
}
bool intersectHH(const L &h, const L &k) {
  return intersectLH(h, k) && intersectLH(k, h);
}
bool intersectHS2(const L &h, const L &s) {
  L t(s);
  swap(t[0], t[1]);
  return intersectHH(h, s) && intersectHH(h, t);
}
complex<double> projection(const L &l, const complex<double> &p) {
  double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
  return l[0] + t * (l[0] - l[1]);
}
complex<double> reflection(const L &l, const complex<double> &p) {
  return p + complex<double>(2, 0) * (projection(l, p) - p);
}
vector<L> tangentCP(const C &c, const complex<double> &p) {
  vector<L> ret;
  complex<double> vect = c.p - p;
  double d = abs(vect);
  double l = sqrt(d * d - c.r * c.r);
  if (::isnan(l)) {
    return ret;
  }
  complex<double> v1 = vect * complex<double>(l / d, c.r / d);
  complex<double> v2 = vect * complex<double>(l / d, -c.r / d);
  ret.push_back(L(p, p + v1));
  if (l > EPS) ret.push_back(L(p, p + v2));
  return ret;
}
complex<double> crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0];
  if (abs(A) < EPS) assert(false);
  return m[0] + B / A * (m[1] - m[0]);
}
double distanceSP(const L &s, const complex<double> &p) {
  const complex<double> r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
C circles[10];
int n, d;
double ans;
complex<double> start(25, 0);
complex<double> goal(25, 94);
void check(const complex<double> &p) {
  if (p.real() < -EPS || p.real() > 50 + EPS || p.imag() < -EPS ||
      p.imag() > 94 + EPS) {
    return;
  }
  int cnt = 0;
  for (int i = 0; i < (int)(n); ++i) {
    if (distanceSP(L(start, p), circles[i].p) <= circles[i].r - EPS ||
        distanceSP(L(goal, p), circles[i].p) <= circles[i].r - EPS) {
      cnt++;
    }
  }
  if (cnt <= d) {
    (ans > abs(start - p) + abs(goal - p)
         ? (ans = abs(start - p) + abs(goal - p), 1)
         : 0);
  }
}
int main() {
  while (cin >> n >> d) {
    for (int i = 0; i < (int)(n); ++i) {
      int x, y, r;
      cin >> x >> y >> r;
      circles[i] = C(complex<double>(x, y), r);
    }
    ans = INF;
    check(start);
    vector<L> v;
    for (int i = 0; i < (int)(n); ++i) {
      vector<L> v1 = tangentCP(circles[i], start);
      vector<L> v2 = tangentCP(circles[i], goal);
      for (__typeof((v1).begin()) it = (v1).begin(); it != (v1).end(); ++it)
        v.push_back(*it);
      for (__typeof((v2).begin()) it = (v2).begin(); it != (v2).end(); ++it)
        v.push_back(*it);
    }
    for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it) {
      for (__typeof((v).begin()) jt = (v).begin(); jt != (v).end(); ++jt) {
        if (intersectLL(*it, *jt)) {
          complex<double> p = crosspoint(*it, *jt);
          check(p);
        }
      }
    }
    if (ans == INF)
      cout << -1 << endl;
    else
      printf("%.10f\n", ans);
  }
}
