#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
long long dp[805][805], dis[maxn];
int tot = 0, n, m, k, b[maxn], cnt = 0;
struct node {
  int u, v, w;
  friend bool operator<(const node& a, const node& b) { return a.w < b.w; }
} a[maxn];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= m; i++) scanf("%d %d %d", &a[i].u, &a[i].v, &a[i].w);
  sort(a + 1, a + m + 1);
  memset(dp, 0x3f, sizeof(dp));
  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);
  int qwq = unique(b + 1, b + cnt + 1) - b - 1;
  for (int i = 1; i <= min(k, m); i++) {
    int from = lower_bound(b + 1, b + qwq + 1, a[i].u) - b,
        to = lower_bound(b + 1, b + qwq + 1, a[i].v) - b;
    dp[from][to] = dp[to][from] = a[i].w;
  }
  for (int k = 1; k <= qwq; k++)
    for (int i = 1; i <= qwq; i++)
      for (int j = 1; j <= qwq; j++)
        if (dp[i][k] + dp[k][j] < dp[i][j]) dp[i][j] = dp[i][k] + dp[k][j];
  for (int i = 1; i <= qwq; i++)
    for (int j = i + 1; j <= qwq; j++) dis[++tot] = dp[i][j];
  sort(dis + 1, dis + tot + 1);
  printf("%lld\n", dis[k]);
}
