#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
set<pair<long long, long long> > se;
vector<pair<long long, long long> > gp[200005];
priority_queue<array<long long, 3>, vector<array<long long, 3> >,
               greater<array<long long, 3> > >
    pq;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    pq.push({w, x, y});
  }
  long long ans = 0;
  for (long long i = 0; i < k; i++) {
    auto j = pq.top();
    ans = j[0];
    if (se.count({min(j[1], j[2]), max(j[1], j[2])}) == 0) {
      se.insert({min(j[1], j[2]), max(j[1], j[2])});
      pq.pop();
      for (auto k : gp[j[1]]) {
        if (se.count({min(k.first, j[2]), max(k.first, j[2])}) == 0) {
          pq.push({k.second + j[0], k.first, j[2]});
        }
      }
      for (auto k : gp[j[2]]) {
        if (se.count({min(k.first, j[1]), max(k.first, j[1])}) == 0) {
          pq.push({k.second + j[0], k.first, j[1]});
        }
      }
      gp[j[1]].push_back({j[2], j[0]});
      gp[j[2]].push_back({j[1], j[0]});
    } else {
      i--;
      pq.pop();
    }
  }
  cout << ans << endl;
  return 0;
}
