#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

typedef double D;
const D EPS = 1e-8;
struct P {
  D x, y;
  P(D x_, D y_) : x(x_), y(y_) { }
  P() { }
};

struct C {
  P p; D r;
  C(P p_, D r_) : p(p_), r(r_) { }
  C() { }
};

struct L {
  P a, b;
  L(P a_, P b_) : a(a_), b(b_) { }
};

P operator +(P a, P b) { return P(a.x+b.x, a.y+b.y); }
P operator -(P a, P b) { return P(a.x-b.x, a.y-b.y); }
P operator *(P p, D s) { return P(p.x*s, p.y*s); }
P vec(P from, P to) { return to - from; }
D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }
D norm(P p) { return inp(p,p); }
D abs(P p) { return sqrt(norm(p)); }

P projection(L l, P p) {
  P a = vec(l.a, l.b);
  P b = vec(l.a, p);
  D t = inp(b, a) / norm(a);
  return l.a + a * t;
}

int sign(D a, D b = 0.0) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

int ccw(P a, P b, P c) {
  b = vec(a, b); c = vec(a, c);
  if(sign(outp(b, c)) > 0) return +1;
  if(sign(outp(b, c)) < 0) return -1;
  if(sign(inp(b, c)) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool iSP(L s, P p) {
  return ccw(s.a, s.b, p) == 0;
}

P rot90(P p) {
  return P(-p.y, p.x);
}

D dSP(L s, P p) {
  P r = projection(s, p);
  if(iSP(s, r)) return abs(vec(p, r));
  return min(abs(vec(p, s.a)), abs(vec(p, s.b)));
}

P cLL(L l, L m) {
  D d = outp(vec(m.a, m.b), vec(l.a, l.b));
  return l.a + vec(l.a, l.b) * outp(vec(m.a, m.b), vec(l.a, m.b)) * (1.0 / d);
}

bool iSC(L s, C c) {
  return sign(dSP(s, c.p), c.r) < 0;
}

vector<P> tangentCP(C c, P p) {
  double x = norm(p - c.p);
  double d = x - c.r * c.r;
  if(sign(d) < 0) return vector<P>();
  d = max(d, 0.0);
  P q1 = (p - c.p) * (c.r * c.r / x);
  P q2 = rot90((p - c.p) * (-c.r * sqrt(d) / x));
  vector<P> ret;
  ret.push_back(c.p + q1 - q2);
  ret.push_back(c.p + q1 + q2);
  return ret;
}

const double gx[2] { 25.0, 25.0 };
const double gy[2] { 0.0, 94.0 };

int main() {
  cout.setf(ios::fixed); cout.precision(10);
  int N, D; cin >> N >> D;
  vector<C> cs(N);
  for(int i = 0; i < N; i++) {
    cin >> cs[i].p.x >> cs[i].p.y >> cs[i].r;
  }

  int k = 0;
  L l(P(gx[0], gy[0]), P(gx[1], gy[1]));
  for(int i = 0; i < N; i++) {
    if(iSC(l, cs[i])) k++;
  }
  if(k <= D) {
    // 曲がる必要がないとき
    cout << 94.0 << endl;
  }
  else {
    // 曲がる必要があるとき
    bool ok = false;
    double res = 1e9;
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
        vector<P> t1 = tangentCP(cs[i], P(gx[0], gy[0]));
        vector<P> t2 = tangentCP(cs[j], P(gx[1], gy[1]));
        for(int a = 0; a < 2; a++) for(int b = 0; b < 2; b++) {
          P s(gx[0], gy[0]);
          L l1(s, t1[a]);
          if(sign(abs(vec(t1[a], s))) == 0) {
            P p = rot90(vec(cs[i].p, s));
            l1 = L(s, s + p);
          }
          P g(gx[1],gy[1]);
          L l2(g, t2[b]);
          if(sign(abs(vec(t2[b], g))) == 0) {
            P p = rot90(vec(cs[j].p, g));
            l2 = L(g, g + p);
          }
          P cp = cLL(l1, l2);
          if(!(sign(0.0, cp.x) < 0 && sign(cp.x, 50.0) < 0 && sign(0.0, cp.y) < 0 && sign(cp.y, 94.0) < 0)) {
            continue;
          }
          l1 = L(P(gx[0], gy[0]), cp);
          l2 = L(P(gx[1], gy[1]), cp);

          int damage = 0;
          for(int k = 0; k < N; k++) {
            int x = (int)iSC(l1, cs[k]) + (int)iSC(l2, cs[k]);
            if(x == 1) {
              damage++;
            }
            else if(x == 2) {
              if(sign(abs(vec(cs[k].p, cp)), cs[k].r) < 0) {
                damage++;
              }
              else {
                damage+=2;
              }
            }
          }

          if(damage <= D) {
            ok = true;
            if(res > abs(l1.a - l1.b) + abs(l2.a - l2.b)) {
              res = abs(l1.a - l1.b) + abs(l2.a - l2.b);
            }
          }
        }
      }
    }
    if(ok) {
      cout << res << endl;
    }
    else {
      cout << "-1" << endl;
    }
  }
}