#include <bits/stdc++.h>
inline double dis(std::pair<double, double> x, std::pair<double, double> y) {
  return std::sqrt((x.first - y.first) * (x.first - y.first) +
                   (x.second - y.second) * (x.second - y.second));
}
inline bool chk(std::pair<double, double> x, std::pair<double, double> y,
                std::pair<double, double> z) {
  return std::fabs((y.first - x.first) * (z.second - x.second) -
                   (z.first - x.first) * (y.second - x.second)) < 1e-9;
}
int n, m;
std::pair<double, double> a[200005], b;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lf%lf", &a[i].first, &a[i].second);
  b = a[m];
  if (chk(a[1], a[2], a[3])) {
    for (int i = 4; i <= n; i++)
      if (!chk(a[1], a[2], a[i])) {
        std::swap(a[i], a[n]);
        break;
      }
  } else if (n > 3) {
    if (chk(a[1], a[2], a[4]))
      std::swap(a[3], a[n]);
    else if (chk(a[1], a[3], a[4]))
      std::swap(a[2], a[n]);
    else
      std::swap(a[1], a[n]);
  }
  std::sort(a + 1, a + n);
  for (int i = 1; i <= n; i++)
    if (a[i] == b) m = i;
  if (m == n)
    return printf("%.11lf\n", std::min(dis(a[n], a[1]), dis(a[n], a[n - 1])) +
                                  dis(a[1], a[n - 1])),
           0;
  double ans =
      dis(a[1], a[n - 1]) + std::min(dis(a[m], a[1]) + dis(a[n - 1], a[n]),
                                     dis(a[m], a[n - 1]) + dis(a[1], a[n]));
  for (int i = 1; i < n - 1; i++) {
    std::pair<double, double> A = a[i], B = a[i + 1], C = a[1], D = a[n - 1];
    if (i < m) std::swap(A, B), std::swap(C, D);
    ans = std::min(ans, std::min(dis(a[m], A) + dis(A, C) + dis(C, a[n]) +
                                     dis(a[n], B) + dis(B, D),
                                 dis(a[m], C) + dis(C, A) + dis(A, a[n]) +
                                     dis(a[n], B) + dis(B, D)));
  }
  printf("%.11lf\n", ans);
}

### Prompt

Create a solution in cpp for the following problem:

You are given N points on an infinite plane with the Cartesian coordinate system on it. N-1 points lay on one line, and one point isn't on that line. You are on point K at the start, and the goal is to visit every point. You can move between any two points in a straight line, and you can revisit points. What is the minimum length of the path? 

Input

The first line contains two integers: N (3 ≤ N ≤ 2*10^5) - the number of points, and K (1 ≤ K ≤ N) - the index of the starting point.

Each of the next N lines contain two integers, A_i, B_i (-10^6 ≤ A_i, B_i ≤ 10^6) - coordinates of the i-th point.

Output

The output contains one number - the shortest path to visit all given points starting from point K. The absolute difference between your solution and the main solution shouldn't exceed 10^-6;

Example

Input


5 2
0 0
-1 1
2 -2
0 1
-2 2


Output


7.478709

Note

The shortest path consists of these moves: 

2 -> 5 

5 -> 4 

4 -> 1 

1 -> 3 

There isn't any shorter path possible.

### Response

```cpp
#include <bits/stdc++.h>
inline double dis(std::pair<double, double> x, std::pair<double, double> y) {
  return std::sqrt((x.first - y.first) * (x.first - y.first) +
                   (x.second - y.second) * (x.second - y.second));
}
inline bool chk(std::pair<double, double> x, std::pair<double, double> y,
                std::pair<double, double> z) {
  return std::fabs((y.first - x.first) * (z.second - x.second) -
                   (z.first - x.first) * (y.second - x.second)) < 1e-9;
}
int n, m;
std::pair<double, double> a[200005], b;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lf%lf", &a[i].first, &a[i].second);
  b = a[m];
  if (chk(a[1], a[2], a[3])) {
    for (int i = 4; i <= n; i++)
      if (!chk(a[1], a[2], a[i])) {
        std::swap(a[i], a[n]);
        break;
      }
  } else if (n > 3) {
    if (chk(a[1], a[2], a[4]))
      std::swap(a[3], a[n]);
    else if (chk(a[1], a[3], a[4]))
      std::swap(a[2], a[n]);
    else
      std::swap(a[1], a[n]);
  }
  std::sort(a + 1, a + n);
  for (int i = 1; i <= n; i++)
    if (a[i] == b) m = i;
  if (m == n)
    return printf("%.11lf\n", std::min(dis(a[n], a[1]), dis(a[n], a[n - 1])) +
                                  dis(a[1], a[n - 1])),
           0;
  double ans =
      dis(a[1], a[n - 1]) + std::min(dis(a[m], a[1]) + dis(a[n - 1], a[n]),
                                     dis(a[m], a[n - 1]) + dis(a[1], a[n]));
  for (int i = 1; i < n - 1; i++) {
    std::pair<double, double> A = a[i], B = a[i + 1], C = a[1], D = a[n - 1];
    if (i < m) std::swap(A, B), std::swap(C, D);
    ans = std::min(ans, std::min(dis(a[m], A) + dis(A, C) + dis(C, a[n]) +
                                     dis(a[n], B) + dis(B, D),
                                 dis(a[m], C) + dis(C, A) + dis(A, a[n]) +
                                     dis(a[n], B) + dis(B, D)));
  }
  printf("%.11lf\n", ans);
}

```