#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
struct Vector {
	int x, y;
	int cross(const Vector that) const { return x * that.y - y * that.x; }
	int dot(const Vector that) const { return x * that.x + y * that.y; }
};
struct Point {
	int x, y;
	double distance(const Point that) const {
		return std::sqrt((x - that.x) * (x - that.x) + (y - that.y) * (y - that.y));
	}
	Vector operator-(const Point& that) const {
		return Vector{ x - that.x, y - that.y };
	}
};
struct Edge {
	Point from, to;
	bool has_catheti(const Point& that) const {
		return (to - from).dot(that - from) >= 0 && (from - to).dot(that - to) >= 0;
	}
	double catheti_length(const Point& that) const {
		return std::abs((to.y - from.y) * that.x - (to.x - from.x) * that.y + to.x * from.y - to.y * from.x) / std::sqrt((to.y - from.y) * (to.y - from.y) + (to.x - from.x) * (to.x - from.x));
	}
	double length() const { return from.distance(to); }
};
int main() {
	int n, m, x, y; std::cin >> n >> m >> x >> y;
	std::vector<Point> points(n + 1); points[0] = Point{ x, y };
	for (auto i = 1; i <= n; ++i) std::cin >> points[i].x >> points[i].y;
	std::vector<double> nearest_distance_to_point(n + 1, DBL_MAX), nearest_distance_to_edge(n + 1, DBL_MAX);
	std::vector<int> nearest_point(n + 1, 0);
	std::vector<int> rest(n + 1, -1); for (auto i = 0; i < n; ++i) rest[i] = i + 1;
	auto comparator = [](const std::pair<int, double>& a, const std::pair<int, double>& b) { return (std::abs(a.second - b.second) < 0.0000000001) ? a.first > b.first : a.second > b.second; };
	std::priority_queue<std::pair<int, double>, std::vector<std::pair<int, double>>, decltype(comparator)> queue(comparator);
	for (auto i = 1; i <= n; ++i) {
		nearest_distance_to_point[i] = points[0].distance(points[i]);
		queue.emplace(i, nearest_distance_to_point[i]);
		if (nearest_distance_to_point[0] < nearest_distance_to_point[i]) {
			nearest_distance_to_point[0] = nearest_distance_to_point[i];
			nearest_point[0] = i;
		}
	}
	double result = 0;
	for (auto c = 0; c < m; ++c) {
		while (nearest_point[queue.top().first] == -1) queue.pop();
		auto top = queue.top(); queue.pop();
		auto edge = Edge{ points[top.first], points[nearest_point[top.first]] };
		result += nearest_distance_to_point[top.first];
		nearest_point[top.first] = -1;
		for (auto i = 0; i < n - c - 1; ++i) {
			if (rest[i] == top.first) {
				rest[i] = rest[n - c - 1];
			}
			auto distance = points[top.first].distance(points[rest[i]]);
			if (nearest_distance_to_point[rest[i]] > distance) {
				nearest_distance_to_point[rest[i]] = distance;
				nearest_point[rest[i]] = top.first;
				if (nearest_distance_to_edge[rest[i]] > distance) {
					nearest_distance_to_edge[rest[i]] = distance;
					queue.emplace(rest[i], distance);
				}
			}
			if (edge.has_catheti(points[rest[i]])) {
				auto d = edge.catheti_length(points[rest[i]]);
				if (nearest_distance_to_edge[rest[i]] > d) {
					nearest_distance_to_edge[rest[i]] = d;
					queue.emplace(rest[i], d);
				}
			}
		}
	}
	std::cout << std::setprecision(15) << std::fixed << result << std::endl;
}


Measured memory_bytes: 35880