#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
bool operator<(const complex<double> a, const complex<double> b) {
  return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
}
}  // namespace std
double cross(const complex<double> a, const complex<double> b) {
  return (conj(a) * b).imag();
}
double dot(const complex<double> a, const complex<double> b) {
  return (conj(a) * b).real();
}
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return +1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
struct L : public vector<complex<double> > {
  L(const complex<double> a, const complex<double> b) {
    push_back(a), push_back(b);
  }
};
struct C {
  complex<double> p;
  double r;
  C(const complex<double> p, double r) : p(p), r(r) {}
};
complex<double> projection(L a, complex<double> p) {
  double t = dot(p - a[0], a[0] - a[1]) / norm(a[0] - a[1] + EPS);
  return a[0] + t * (a[0] - a[1]);
}
complex<double> reflection(L a, complex<double> p) {
  return p + 2.0 * (projection(a, p) - p);
}
bool isCrossLL(L a, L b) {
  return abs(cross(a[1] - a[0], b[1] - b[0])) > EPS ||
         abs(cross(a[1] - a[0], b[0] - a[0])) < EPS;
}
complex<double> crossP_LL(L a, L b) {
  double A = cross(a[1] - a[0], b[1] - b[0]);
  double B = cross(a[1] - a[0], a[1] - b[0]);
  if (abs(A) < EPS && abs(B) < EPS) return b[0];
  if (abs(A) < EPS) assert(false);
  return b[0] + B / A * (b[1] - b[0]);
}
vector<L> TLine_CP(C c, complex<double> p) {
  complex<double> v = c.p - p;
  double t = asin(abs(c.r) / (abs(v)));
  complex<double> e = v / abs(v) * exp(complex<double>(.0, t));
  complex<double> n1 = sqrt(abs(v) * abs(v) - c.r * c.r) * e + p;
  complex<double> n2 = reflection(L(p, c.p), n1);
  vector<L> ret;
  ret.push_back(L(p, n1));
  ret.push_back(L(p, n2));
  return ret;
}
bool isCrossSP(L a, complex<double> p) {
  return abs(a[0] - p) + abs(a[1] - p) - abs(a[0] - a[1]) < EPS;
}
double distSP(L a, complex<double> p) {
  const complex<double> r = projection(a, p);
  bool f = isCrossSP(a, r);
  return f ? abs(p - r) : min(abs(a[0] - p), abs(a[1] - p));
}
double distPP(complex<double> a, complex<double> b) { return abs(a - b); }
int n, m;
vector<C> cir;
void input() {
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    cir.push_back(C(complex<double>(a, b), c));
  }
}
class Path : public vector<L> {
 public:
  Path(L a) { push_back(a); }
  Path(L a, L b) {
    push_back(a);
    push_back(b);
  }
};
vector<Path> path;
void makeLines() {
  complex<double> st(25, 0);
  complex<double> en(25, 94);
  path.push_back(Path(L(st, en)));
  for (int i = 0; i < int(cir.size()); i++) {
    for (int j = 0; j < int(cir.size()); j++) {
      vector<L> ps = TLine_CP(cir[i], st);
      vector<L> pe = TLine_CP(cir[j], en);
      for (int k = 0; k < int(ps.size()); k++) {
        for (int p = 0; p < int(pe.size()); p++) {
          path.push_back(Path(ps[k], pe[p]));
        }
      }
    }
  }
}
void printLines() {
  for (int i = 0; i < int(path.size()); i++) {
    for (int j = 0; j < int(path[i].size()); j++) {
      printf("(%lf,%lf)-(%lf,%lf) ", path[i][j][0].real(), path[i][j][0].imag(),
             path[i][j][1].real(), path[i][j][1].imag());
    }
    puts("");
  }
}
bool boxin(complex<double> p) {
  return p.real() > -EPS && p.real() < 50 + EPS && p.imag() > -EPS &&
         p.imag() < 94 + EPS;
}
void removeOut() {
  for (int i = 0; i < int(path.size()); i++) {
    bool flg = true;
    for (int j = 0; j < int(path[i].size() - 1); j++) {
      if (isCrossLL(path[i][j], path[i][j + 1])) {
        complex<double> p = crossP_LL(path[i][j], path[i][j + 1]);
        path[i][j][1] = p;
        path[i][j + 1][1] = p;
        if (!boxin(p)) flg = false;
      } else {
        flg = false;
      }
    }
    if (!flg) {
      path.erase(path.begin() + i);
      i--;
    }
  }
}
void removeCircleOn() {
  for (int i = 0; i < int(path.size()); i++) {
    int count = 0;
    for (int k = 0; k < int(cir.size()); k++) {
      bool hit = false;
      for (int j = 0; j < int(path[i].size()); j++) {
        double dist = distSP(path[i][j], cir[k].p);
        if (dist + EPS < cir[k].r) hit = true;
      }
      if (hit) count++;
    }
    if (count > m) {
      path.erase(path.begin() + i);
      i--;
    }
  }
}
double minLength() {
  double mini = INF;
  for (int i = 0; i < int(path.size()); i++) {
    double sum = 0;
    for (int j = 0; j < int(path[i].size()); j++) {
      sum += distPP(path[i][j][0], path[i][j][1]);
    }
    mini = min(sum, mini);
  }
  if (mini == INF) return -1;
  return mini;
}
double solve() {
  makeLines();
  removeOut();
  removeCircleOn();
  return minLength();
}
int main() {
  input();
  printf("%.12lf\n", solve());
}
