#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
struct edge {
  long long u, v, w;
};
class edgeCompare {
 public:
  bool operator()(edge a, edge b) { return a.w > b.w; }
};
int32_t main() {
  c_p_c();
  long long n, te, k;
  cin >> n >> te >> k;
  priority_queue<edge, vector<edge>, edgeCompare> pq;
  for (long long i = 0; i < te; i++) {
    edge e;
    cin >> e.u >> e.v >> e.w;
    pq.push(e);
  }
  map<long long, vector<pair<long long, long long> > > m;
  set<pair<long long, long long> > s;
  long long wt;
  while (k > 0) {
    edge e = pq.top();
    pq.pop();
    if (s.find(make_pair(e.u, e.v)) != s.end() ||
        s.find(make_pair(e.v, e.u)) != s.end())
      continue;
    edge et;
    if (m[e.u].size() != 0) {
      for (auto p : m[e.u]) {
        if (p.first != e.u && s.find(make_pair(p.first, e.v)) == s.end() &&
            s.find(make_pair(e.v, p.first)) == s.end()) {
          et.u = p.first;
          et.v = e.v;
          et.w = e.w + p.second;
          pq.push(et);
        }
      }
    }
    if (m[e.v].size() != 0) {
      for (auto p : m[e.v]) {
        if (p.first != e.v && s.find(make_pair(p.first, e.u)) == s.end() &&
            s.find(make_pair(e.u, p.first)) == s.end()) {
          et.u = p.first;
          et.v = e.u;
          et.w = e.w + p.second;
          pq.push(et);
        }
      }
    }
    s.insert(make_pair(e.u, e.v));
    m[e.u].push_back(make_pair(e.v, e.w));
    m[e.v].push_back(make_pair(e.u, e.w));
    k--;
    if (k == 0) wt = e.w;
  }
  cout << wt << "\n";
}
