#include <bits/stdc++.h>
using namespace std;
long long dp[810][810], dis[500010];
int n, m, k, b[500010], tot = 0, cnt = 0;
struct node {
  int u, v, w;
} a[500010];
bool cmp(node x, node y) { return x.w < y.w; }
int main() {
  memset(dp, 0x3f, sizeof(dp));
  cin >> n >> m >> k;
  for (int i = 1; i <= m; ++i) cin >> a[i].u >> a[i].v >> a[i].w;
  sort(a + 1, a + m + 1, cmp);
  for (int i = 1; i <= min(k, m); i++) b[++cnt] = a[i].u, b[++cnt] = a[i].v;
  sort(b + 1, b + cnt + 1);
  n = unique(b + 1, b + cnt + 1) - b - 1;
  for (int i = 1; i <= min(k, m); ++i) {
    int from = lower_bound(b + 1, b + n + 1, a[i].u) - b;
    int to = lower_bound(b + 1, b + n + 1, a[i].v) - b;
    dp[from][to] = a[i].w;
    dp[to][from] = a[i].w;
  }
  for (int kk = 1; kk <= n; ++kk)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (dp[i][kk] + dp[kk][j] < dp[i][j]) dp[i][j] = dp[i][kk] + dp[kk][j];
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (dp[i][j] != 0x3f3f3f3f3f3f3f3f) dis[++tot] = dp[i][j];
  sort(dis + 1, dis + tot + 1);
  cout << dis[k] << endl;
  return 0;
}
