#include <bits/stdc++.h>
using namespace std;
using Z = int64_t;
const Z INF = 1LL << 55;
vector<vector<Z>> d;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<Z, pair<int, int>>> edges;
  for (int i = 0; i < m; ++i) {
    int x, y;
    Z w;
    cin >> x >> y >> w;
    auto p = make_pair(x, y);
    edges.push_back(make_pair(w, p));
  }
  sort(edges.begin(), edges.end());
  int c = 0;
  unordered_map<int, int> mp;
  int i = 0;
  for (auto& e : edges) {
    if (i >= k) break;
    i++;
    int x = e.second.first;
    int y = e.second.second;
    if (mp.find(x) == mp.end())
      e.second.first = mp[x] = c++;
    else
      e.second.first = mp[x];
    if (mp.find(y) == mp.end())
      e.second.second = mp[y] = c++;
    else
      e.second.second = mp[y];
  }
  d.assign(c, vector<Z>(c, INF));
  int j = 0;
  for (auto e : edges) {
    if (++j > i) break;
    int x = e.second.first;
    int y = e.second.second;
    d[x][y] = e.first;
    d[y][x] = e.first;
  }
  for (int a = 0; a < c; ++a) d[a][a] = 0;
  for (int a = 0; a < c; ++a) {
    for (int p = 0; p < c; ++p) {
      for (int q = 0; q < c; ++q) {
        if (d[p][a] == INF || d[a][q] == INF) continue;
        d[p][q] = min(d[p][q], d[p][a] + d[a][q]);
      }
    }
  }
  vector<Z> dist;
  for (int p = 0; p < c; ++p) {
    for (int q = p + 1; q < c; ++q) {
      dist.push_back(d[p][q]);
    }
  }
  sort(dist.begin(), dist.end());
  cout << dist[k - 1];
}
