#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200200;
long long inf = 0;
long long n, m, k;
long long a[maxn], b[maxn], w[maxn];
long long c[maxn];
long long I[maxn];
long long d[808][808];
long long wk;
vector<long long> x, y;
void add_v(long long v) {
  if (~I[v]) return;
  I[v] = x.size();
  x.push_back(v);
}
int32_t main() {
  memset(I, -1, sizeof I);
  memset(d, 30, sizeof d);
  inf = d[0][0];
  for (long long i = 0; i < 808; i++) d[i][i] = 0;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  x.reserve(n);
  y.reserve(808 * 808);
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> w[i];
    a[i]--, b[i]--, c[i] = w[i];
  }
  sort(c, c + m);
  c[m] = inf;
  wk = c[min(k - 1, m)];
  for (long long i = 0; i < m; i++)
    if (w[i] < wk) {
      add_v(a[i]), add_v(b[i]);
      a[i] = I[a[i]];
      b[i] = I[b[i]];
      d[a[i]][b[i]] = d[b[i]][a[i]] = w[i];
    }
  n = x.size();
  for (long long i = 0; i < m; i++)
    if (w[i] < wk)
      for (long long v = 0; v < n; v++)
        for (long long u = 0; u < n; u++) {
          d[v][u] = min(d[v][u], d[v][a[i]] + d[b[i]][u] + w[i]);
          d[u][v] = d[v][u];
        }
  for (long long v = 0; v < n; v++)
    for (long long u = 0; u < v; u++)
      if (d[v][u] < inf) y.push_back(d[v][u]);
  sort(y.begin(), y.end());
  if (y.size() >= k) wk = min(wk, y[k - 1]);
  cout << wk << endl;
  return 0;
}
