#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using pii = pair<int, int>;
using VP = vector<pii>;
using pi3 = pair<LL, pii>;
const int N = 2e5 + 10;
const LL inf = 0x3f3f3f3f3f3f3f3fll;
VP adj[N];
int flag[N];
LL dis[N];
int main() {
  int n, m, k, cur = 0;
  cin >> n >> m >> k;
  for (int i = 0, u, v, w; i < m; i++) {
    scanf("%d %d %d", &u, &v, &w);
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end(),
         [](const pii& a, const pii& b) { return a.second < b.second; });
  }
  set<pi3> st;
  set<pii> s;
  auto add = [&](int u, int v, LL d) {
    if (u > v) swap(u, v);
    st.insert({d, {u, v}});
    while (st.size() > k) {
      st.erase(--st.end());
    }
  };
  for (int i = 1; i <= n; i++) {
    cur++;
    s.clear();
    flag[i] = cur;
    dis[i] = 0;
    s.insert({0, i});
    for (int j = 0; !s.empty() && j < min(n, k + 1); j++) {
      int u = s.begin()->second;
      s.erase(s.begin());
      if (st.size() == k && (--st.end())->first <= dis[u]) {
        break;
      }
      if (u != i) {
        add(i, u, dis[u]);
      }
      for (auto v : adj[u]) {
        if (st.size() == k && (--st.end())->first <= dis[u] + v.second) {
          break;
        }
        if (flag[v.first] != cur) {
          flag[v.first] = cur;
          dis[v.first] = inf;
          s.insert({dis[v.first], v.first});
        }
        if (dis[v.first] > dis[u] + v.second) {
          s.erase({dis[v.first], v.first});
          dis[v.first] = dis[u] + v.second;
          s.insert({dis[v.first], v.first});
        }
      }
    }
  }
  cout << ((--st.end())->first) << endl;
  return 0;
}
