#include <bits/stdc++.h>
using namespace std;
struct pt {
  int x, y, id;
  pt() {}
  pt(int x, int y) : x(x), y(y) {}
} a[1000005];
bool operator<(const pt a, const pt b) {
  return a.x == b.x ? a.y < b.y : a.x < b.x;
}
pt operator-(const pt a, const pt b) { return pt(a.x - b.x, a.y - b.y); }
long long Cross(const pt a, const pt b) {
  return 1ll * a.x * b.y - 1ll * a.y * b.x;
}
double F(int i, int j) {
  return sqrt(1ll * (a[i].x - a[j].x) * (a[i].x - a[j].x) +
              1ll * (a[i].y - a[j].y) * (a[i].y - a[j].y));
}
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y), a[i].id = i;
  if (n > 3) {
    long long ans1 = Cross(a[2] - a[1], a[3] - a[1]),
              ans2 = Cross(a[4] - a[1], a[3] - a[1]);
    long long ans3 = Cross(a[2] - a[1], a[4] - a[1]);
    if (ans1 && ans2 && ans3)
      swap(a[1], a[n]);
    else if (ans1 && ans3)
      swap(a[2], a[n]);
    else if (ans1 && ans2)
      swap(a[3], a[n]);
    else if (ans2 && ans3)
      swap(a[4], a[n]);
    else {
      for (int i = 3; i <= n; i++)
        if (Cross(a[2] - a[1], a[i] - a[1])) {
          swap(a[i], a[n]);
          break;
        }
    }
  }
  sort(a + 1, a + n);
  for (int i = 1; i <= n; i++)
    if (a[i].id == k) {
      k = i;
      break;
    }
  double ans = 1e18;
  if (k == n) {
    ans = min(ans, F(1, n - 1) + min(F(1, n), F(n - 1, n)));
    printf("%.10f\n", ans);
    return 0;
  }
  ans = min(ans, F(k, n) + F(1, n - 1) + min(F(1, n), F(n - 1, n)));
  ans =
      min(ans, F(1, n - 1) + min(F(1, n) + F(n - 1, k), F(n - 1, n) + F(1, k)));
  ans = min(ans, F(k, 1) + F(1, n) +
                     (k == n - 1 ? 0 : F(n, k + 1) + F(k + 1, n - 1)));
  ans = min(ans, F(k, n - 1) + F(n - 1, n) +
                     (k == 1 ? 0 : F(n, k - 1) + F(k - 1, 1)));
  for (int i = 2; i <= k; i++)
    ans = min(ans, F(1, i - 1) + min(F(i - 1, n), F(1, n)) + F(i, n) +
                       F(i, n - 1) + F(k, n - 1));
  for (int i = k; i < n - 1; i++)
    ans = min(ans, F(k, 1) + F(1, i) + F(i, n) + min(F(n, i + 1), F(n, n - 1)) +
                       F(i + 1, n - 1));
  printf("%.10f\n", ans);
  return 0;
}

### Prompt

Generate a Cpp solution to 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>
using namespace std;
struct pt {
  int x, y, id;
  pt() {}
  pt(int x, int y) : x(x), y(y) {}
} a[1000005];
bool operator<(const pt a, const pt b) {
  return a.x == b.x ? a.y < b.y : a.x < b.x;
}
pt operator-(const pt a, const pt b) { return pt(a.x - b.x, a.y - b.y); }
long long Cross(const pt a, const pt b) {
  return 1ll * a.x * b.y - 1ll * a.y * b.x;
}
double F(int i, int j) {
  return sqrt(1ll * (a[i].x - a[j].x) * (a[i].x - a[j].x) +
              1ll * (a[i].y - a[j].y) * (a[i].y - a[j].y));
}
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y), a[i].id = i;
  if (n > 3) {
    long long ans1 = Cross(a[2] - a[1], a[3] - a[1]),
              ans2 = Cross(a[4] - a[1], a[3] - a[1]);
    long long ans3 = Cross(a[2] - a[1], a[4] - a[1]);
    if (ans1 && ans2 && ans3)
      swap(a[1], a[n]);
    else if (ans1 && ans3)
      swap(a[2], a[n]);
    else if (ans1 && ans2)
      swap(a[3], a[n]);
    else if (ans2 && ans3)
      swap(a[4], a[n]);
    else {
      for (int i = 3; i <= n; i++)
        if (Cross(a[2] - a[1], a[i] - a[1])) {
          swap(a[i], a[n]);
          break;
        }
    }
  }
  sort(a + 1, a + n);
  for (int i = 1; i <= n; i++)
    if (a[i].id == k) {
      k = i;
      break;
    }
  double ans = 1e18;
  if (k == n) {
    ans = min(ans, F(1, n - 1) + min(F(1, n), F(n - 1, n)));
    printf("%.10f\n", ans);
    return 0;
  }
  ans = min(ans, F(k, n) + F(1, n - 1) + min(F(1, n), F(n - 1, n)));
  ans =
      min(ans, F(1, n - 1) + min(F(1, n) + F(n - 1, k), F(n - 1, n) + F(1, k)));
  ans = min(ans, F(k, 1) + F(1, n) +
                     (k == n - 1 ? 0 : F(n, k + 1) + F(k + 1, n - 1)));
  ans = min(ans, F(k, n - 1) + F(n - 1, n) +
                     (k == 1 ? 0 : F(n, k - 1) + F(k - 1, 1)));
  for (int i = 2; i <= k; i++)
    ans = min(ans, F(1, i - 1) + min(F(i - 1, n), F(1, n)) + F(i, n) +
                       F(i, n - 1) + F(k, n - 1));
  for (int i = k; i < n - 1; i++)
    ans = min(ans, F(k, 1) + F(1, i) + F(i, n) + min(F(n, i + 1), F(n, n - 1)) +
                       F(i + 1, n - 1));
  printf("%.10f\n", ans);
  return 0;
}

```