#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const double INF = 1e18; void solve() { ll n, k; cin >> n >> k; vector x(n), y(n); rep(i, n) cin >> x[i] >> y[i]; auto dist = [&](ll sx, ll sy, ll tx, ll ty) -> double { ll dx = tx - sx, dy = ty - sy; return sqrt(double(dx * dx + dy * dy)); }; vector dp(1 << n, vector(n, vector(k, INF + 10))); rep(i, n) dp[1 << i][i][k - 1] = dist(0, 0, x[i], y[i]); rep(S, 1 << n) rep(pi, n) rep(pk, k) if (dp[S][pi][pk] < INF) { rep(ni, n) if (((S >> ni) & 1) == 0) { ll T = S | (1 << ni); if (pk > 0) { double d = dist(x[pi], y[pi], x[ni], y[ni]); dp[T][ni][pk - 1] = min(dp[T][ni][pk - 1], dp[S][pi][pk] + d); } { double d = dist(x[pi], y[pi], 0, 0); d += dist(0, 0, x[ni], y[ni]); dp[T][ni][k - 1] = min(dp[T][ni][k - 1], dp[S][pi][pk] + d); } } } double ans = INF; rep(i, n) rep(ki, k) ans = min(ans, dp[(1 << n) - 1][i][ki] + dist(x[i], y[i], 0, 0)); cout << fixed << setprecision(11) << ans << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }