#include <bits/stdc++.h>
using namespace std;
mt19937 parsa(chrono::steady_clock::now().time_since_epoch().count());
const long long MAXN = 2 * 100 * 1000 + 17, inf = 1e17;
long long n, m, d[MAXN], k, b[MAXN];
priority_queue<long long> ans;
vector<pair<int, int>> adj[MAXN];
void dij(int v) {
  vector<int> ver;
  d[v] = 0;
  set<pair<int, int>> s;
  s.insert({0, v});
  while (s.size()) {
    int u = s.begin()->second;
    s.erase(s.begin());
    ver.push_back(u);
    if (ans.size() == k && ans.top() <= d[u])
      continue;
    else if (u <= v)
      ;
    else {
      if (ans.size() < k)
        ans.push(d[u]);
      else {
        ans.pop();
        ans.push(d[u]);
      }
    }
    for (auto i : adj[u]) {
      long long z = i.first, w = i.second;
      if (w + d[u] < d[z]) {
        s.erase({d[z], z});
        d[z] = d[u] + w;
        s.insert({d[z], z});
      }
    }
  }
  for (auto i : ver) d[i] = inf;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) d[i] = inf;
  vector<pair<int, pair<int, int>>> edge;
  for (int i = 1; i <= m; i++) {
    int v, u, w;
    cin >> v >> u >> w;
    if (m <= k) {
      adj[v].push_back({u, w});
      adj[u].push_back({v, w});
    } else
      edge.push_back({w, {v, u}});
  }
  if (m > k) {
    sort(edge.begin(), edge.end());
    for (int i = 0; i < k; i++)
      adj[edge[i].second.first].push_back(
          {edge[i].second.second, edge[i].first}),
          adj[edge[i].second.second].push_back(
              {edge[i].second.first, edge[i].first});
  }
  int fr = 1, bk = n;
  for (int i = 1; i <= n; i++)
    if (i % 2)
      dij(fr++);
    else
      dij(bk--);
  cout << ans.top() << endl;
  return 0;
}
