#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
const long long inf = 1e16;
long long N, M, K;
struct edge {
  long long u, v, w;
  bool operator<(const edge& o) const { return w < o.w; }
} edges[maxn];
long long V[maxn], cntV;
long long dp[888][888];
vector<long long> res;
void init() {
  for (int i = 0; i < 888; i++) {
    for (int j = 0; j < 888; j++) dp[i][j] = inf;
  }
}
void floyd() {
  for (int k = 0; k < cntV; k++) {
    for (int i = 0; i < cntV; i++) {
      for (int j = 0; j < cntV; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
}
int main() {
  init();
  cin >> N >> M >> K;
  for (long long i = 0; i < M; i++) {
    scanf("%lld%lld%lld", &edges[i].u, &edges[i].v, &edges[i].w);
  }
  sort(edges, edges + M);
  for (long long i = 0; i < K; i++) {
    V[cntV++] = edges[i].u;
    V[cntV++] = edges[i].v;
  }
  sort(V, V + cntV);
  cntV = unique(V, V + cntV) - V;
  for (long long i = 0; i < K; i++) {
    long long u = lower_bound(V, V + cntV, edges[i].u) - V;
    long long v = lower_bound(V, V + cntV, edges[i].v) - V;
    long long w = edges[i].w;
    dp[u][v] = dp[v][u] = w;
  }
  floyd();
  for (long long i = 0; i < cntV; i++) {
    for (long long j = i + 1; j < cntV; j++) {
      res.push_back(dp[i][j]);
    }
  }
  sort(res.begin(), res.end());
  cout << res[K - 1] << endl;
  return 0;
}
