#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const long long int inf = 1e16;
vector<pair<long long int, long long int>> adj[N];
vector<long long int> vec, v;
vector<pair<long long int, pair<int, int>>> e;
long long int id[N], dis[N];
set<pair<long long int, long long int>> second;
void dij(int u) {
  for (int i = 0; i < int(v.size()); i++) dis[i] = inf;
  dis[u] = 0;
  for (int i = 0; i < int(v.size()); i++) second.insert({dis[i], i});
  while (!second.empty()) {
    int x = second.begin()->second;
    second.erase(second.begin());
    for (auto it : adj[v[x]]) {
      long long int y = id[it.first], w = it.second;
      if (dis[y] > dis[x] + w) {
        second.erase({dis[y], y});
        dis[y] = dis[x] + w;
        second.insert({dis[y], y});
      }
    }
  }
  for (int i = 0; i < u; i++) vec.push_back(dis[i]);
  return;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    e.push_back({w, {x, y}});
  }
  sort(e.begin(), e.end());
  for (int i = 0; i < min(k, m); i++) {
    int x = e[i].second.first, y = e[i].second.second;
    long long int w = e[i].first;
    adj[x].push_back({y, w});
    adj[y].push_back({x, w});
    v.push_back(x);
    v.push_back(y);
  }
  sort(v.begin(), v.end());
  auto p = unique(v.begin(), v.end());
  v.resize(distance(v.begin(), p));
  for (int i = 0; i < int(v.size()); i++) id[v[i]] = i;
  for (int i = 0; i < int(v.size()); i++) dij(i);
  sort(vec.begin(), vec.end());
  cout << vec[k - 1] << endl;
  return 0;
}
