#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
map<int, int> vis;
struct Edge {
  int u, v;
  long long w;
  bool friend operator<(Edge a, Edge b) { return a.w < b.w; }
} e[N];
long long n, m, k, id;
long long d[810][810];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%I64d", &e[i].u, &e[i].v, &e[i].w);
  }
  sort(e, e + m);
  memset(d, 0x3f, sizeof d);
  for (int i = 0; i < min(k, m); i++) {
    if (!vis[e[i].u]) vis[e[i].u] = ++id;
    d[id][id] = 0;
    if (!vis[e[i].v]) vis[e[i].v] = ++id;
    d[id][id] = 0;
    int u = vis[e[i].u], v = vis[e[i].v];
    d[u][v] = d[v][u] = e[i].w;
  }
  for (int kk = 1; kk <= id; kk++)
    for (int i = 1; i <= id; i++)
      for (int j = 1; j <= id; j++)
        d[j][i] = d[i][j] = min(d[i][j], d[i][kk] + d[kk][j]);
  vector<long long> ans;
  for (int i = 1; i <= id; i++)
    for (int j = 1; j <= id; j++)
      if (i != j) ans.push_back(d[i][j]);
  sort(ans.begin(), ans.end());
  cout << ans[2 * k - 1] << endl;
  return 0;
}
