#include <bits/stdc++.h>
using namespace std;
const int Ni = 2e5 + 5;
struct node {
  int a, b;
  long long int w;
  bool operator<(const node &q) const { return w < q.w; }
} arr[Ni];
long long int e[805][805];
int val[Ni];
long long int ans[Ni];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%lld", &arr[i].a, &arr[i].b, &arr[i].w);
  }
  sort(arr + 1, arr + 1 + m);
  memset(e, 0x3f, sizeof(e));
  int cnt = 1;
  for (int i = 1; i <= k; i++) {
    int a = arr[i].a;
    int b = arr[i].b;
    long long int w = arr[i].w;
    if (val[a] == 0) val[a] = cnt++;
    if (val[b] == 0) val[b] = cnt++;
    e[val[a]][val[b]] = e[val[b]][val[a]] = min(w, e[val[a]][val[b]]);
  }
  for (int r = 1; r < cnt; r++) {
    for (int i = 1; i < cnt; i++) {
      for (int j = 1; j < cnt; j++) {
        if (e[i][j] > e[i][r] + e[r][j]) {
          e[i][j] = e[i][r] + e[r][j];
        }
      }
    }
  }
  int num = 1;
  for (int i = 1; i < cnt; i++) {
    for (int j = i + 1; j < cnt; j++) {
      ans[num++] = e[i][j];
    }
  }
  sort(ans + 1, ans + num);
  printf("%lld\n", ans[k]);
  return 0;
}
