#include <bits/stdc++.h>
using namespace std;
pair<long long, pair<long long, long long> > p[200011];
set<long long> st;
set<long long>::iterator it;
vector<pair<long long, long long> > gr[200011];
vector<long long> Res;
long long dis[200011], inf = 1e18;
void dijksrta(long long source) {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      Q;
  for (int i = 0; i < 200011; i++) dis[i] = inf;
  dis[source] = 0;
  Q.push({0, source});
  while (!Q.empty()) {
    long long node = Q.top().second;
    long long x = Q.top().first;
    Q.pop();
    if (x > dis[node]) continue;
    for (int i = 0; i < gr[node].size(); i++) {
      long long child = gr[node][i].first;
      long long w = gr[node][i].second;
      if (w + x < dis[child]) {
        dis[child] = w + x;
        Q.push({dis[child], child});
      }
    }
  }
  for (int i = 0; i < 200011; i++) {
    if (dis[i] != 0 && dis[i] != inf) Res.push_back(dis[i]);
  }
}
int main() {
  ios::sync_with_stdio(0);
  long long n, m, k, i;
  cin >> n >> m >> k;
  for (i = 0; i < m; i++)
    cin >> p[i].second.first >> p[i].second.second >> p[i].first;
  sort(p, p + m);
  long long z = 0;
  for (i = 0; i < m; i++) {
    if (z < k) {
      long long x = p[i].second.first;
      long long y = p[i].second.second;
      st.insert(x);
      st.insert(y);
      gr[x].push_back({y, p[i].first});
      gr[y].push_back({x, p[i].first});
      z++;
    }
  }
  for (it = st.begin(); it != st.end(); it++) dijksrta(*it);
  sort(Res.begin(), Res.end());
  cout << Res[(2 * k) - 1];
  return 0;
}
