#include <bits/stdc++.h>
using namespace std;

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}


double add(double a, double b) {
    return ( abs(a + b) < EPS * (abs(a) + abs(b)) ) ? 0 : (a + b);
}

bool eq(double a, double b) {
    return abs(a - b) < EPS;
}

bool lt(double a, double b) { // a < b
    return !eq(a, b) && (a < b + EPS);
}

bool gt(double a, double b) { // a > b
    return !eq(a, b) && (a + EPS > b);
}

struct P {
	double x, y;
    bool is_base = false;
    double near_dist = DINF;
    int near_base = 0;
    
    P() { };
	P(double x_, double y_) : x(x_), y(y_) {}

	P operator + (const P &p) {
		return P(add(x, p.x), add(y, p.y));
	}

	P operator - (const P &p) {
		return P(add(x, -p.x), add(y, -p.y));
	}

	P operator * (double d) {
		return P(x * d, y * d);
	}

	P operator / (double d) {
		return P(x / d, y / d);
	}

    bool eq(P p) {
        return ::eq(x, p.x) && ::eq(y, p.y);
    }

	// ??????
	double dot(P p) {
		return add(x * p.x, y * p.y);
	}

	// ??????
	double det(P p) {
		return add(x * p.y, -y * p.x);
	}
};

// ??????a, b??¨???c??¨????????????
P near(P a, P b, P c) {
	P p = b - a;
	P q = c - a;

	double r = p.dot(q) / (p.x * p.x + p.y * p.y);

	if (eq(r, 0) || r < EPS) return a;
	if (eq(r, 1) || r + EPS > 1) return b;
	return a + p * r;
}

// ???a??¨???b????????¢
double dist(P a, P b) {
	double x = a.x - b.x;
	double y = a.y - b.y;
	return sqrt(x * x + y * y);
}

int main(void) {
    int N, M;
    cin >> N >> M;
    ++N;
    vector<P> ps(N);
    rep(i, N) {
        cin >> ps[i].x >> ps[i].y;
    }
    ps[0].is_base = true;

    double most_near_dist = DINF;
    int most_near_p = 0;
    REP(i, 1, N) {
        ps[i].near_dist = dist(ps[0], ps[i]);
        if (lt(ps[i].near_dist, most_near_dist)) {
            most_near_dist = ps[i].near_dist;
            most_near_p = i;
        }
    }

//    cout << "connect: " << most_near_p << endl;
    double sum_dist = most_near_dist;
    ps[most_near_p].is_base = true;
    int mcnt = 1;
    int before_k = 0;

    while (mcnt < M) {
        // update
        int k = most_near_p;
        rep(i, N) {
            if (ps[i].is_base) continue;
            double dist_to_k = dist(ps[i], ps[k]);
            double dist_to_kline = dist(ps[i], near(ps[before_k], ps[k], ps[i]));
            double old_dist_to_k = dist(ps[i], ps[ps[i].near_base]);
            if (lt(dist_to_k, old_dist_to_k)) {
                ps[i].near_base = k;
            }
            double min_dist = lt(dist_to_k, dist_to_kline) ? dist_to_k : dist_to_kline;
            if (lt(min_dist, ps[i].near_dist)) {
                ps[i].near_dist = min_dist;
            }
//            cout << k << " " << i << " " << ps[i].near_dist << endl;
        }

        // search
        most_near_dist = DINF;
        most_near_p = k;
        rep(i, N) {
            if (ps[i].is_base) continue;
            if (lt(ps[i].near_dist, most_near_dist)) {
                most_near_dist = ps[i].near_dist;
                most_near_p = i;
            }
        }

        // connect
//        cout << "connect: " << most_near_p << endl;
        ps[most_near_p].is_base = true;
        sum_dist += dist(ps[most_near_p], ps[ps[most_near_p].near_base]);
        ++mcnt;
        before_k = ps[most_near_p].near_base;
    }

    printf("%.12f\n", sum_dist);

	return 0;
}

Measured memory_bytes: 3376