#include <bits/stdc++.h>
using namespace std;
const int maxe = 2e5 + 10, maxm = 410, inf = 0x3f3f3f3f;
int n, m, k, Hash[maxm << 1], N, Cnt;
long long a[maxm][maxm], ans[maxm * maxm];
struct Edge {
  int u, v, w;
};
Edge e[maxe];
vector<Edge> G[maxm << 1];
bool vis[maxm << 1];
bool cmp(const Edge &a, const Edge &b) { return a.w < b.w; }
void init() {
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      a[i][j] = 1e18;
    }
    a[i][i] = 0;
  }
  return;
}
void floyd() {
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
      }
    }
  }
  return;
}
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = true;
  Hash[Cnt++] = u;
  for (int i = 0; i < G[u].size(); ++i) {
    dfs(G[u][i].v);
  }
  return;
}
void shortestPath(int d) {
  memset(vis, false, sizeof(vis));
  int cnt = 0;
  for (int i = 0; i < d; ++i) {
    if (!vis[i]) {
      Cnt = 0;
      dfs(i);
      sort(Hash, Hash + Cnt);
      int dd = int(unique(Hash, Hash + Cnt) - Hash);
      N = dd;
      init();
      for (int j = 0; j < dd; ++j) {
        int u = Hash[j];
        for (int ii = 0; ii < G[u].size(); ++ii) {
          int v = G[u][ii].v;
          v = int(lower_bound(Hash, Hash + dd, v) - Hash);
          a[j][v] = a[v][j] = G[u][ii].w;
        }
      }
      floyd();
      for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
          ans[cnt++] = a[i][j];
        }
      }
    }
  }
  sort(ans, ans + cnt);
  printf("%lld\n", ans[min(k, 400) - 1]);
}
void solve() {
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    e[i] = {x, y, z};
  }
  sort(e, e + m, cmp);
  int cnt = 0;
  for (int i = 0; i < k && i < 400; ++i) {
    Hash[cnt++] = e[i].u;
    Hash[cnt++] = e[i].v;
  }
  sort(Hash, Hash + cnt);
  int d = int(unique(Hash, Hash + cnt) - Hash);
  for (int i = 0; i < k && i < 400; ++i) {
    int u = e[i].u, v = e[i].v;
    u = int(lower_bound(Hash, Hash + d, u) - Hash);
    v = int(lower_bound(Hash, Hash + d, v) - Hash);
    G[u].push_back({0, v, e[i].w});
    G[v].push_back({0, u, e[i].w});
  }
  shortestPath(d);
  return;
}
int main() {
  while (scanf("%d %d %d", &n, &m, &k) != EOF) solve();
  return 0;
}
