#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int LOG = 20;
const int CNTSZ = 30;
const long long INF = 1e18;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<long long, pair<int, int>>> edges(m);
  for (int i = 0; i < int(m); i++) {
    cin >> edges[i].second.first >> edges[i].second.second >> edges[i].first;
    edges[i].second.first--;
    edges[i].second.second--;
  }
  sort(edges.begin(), edges.end());
  set<int> vrt;
  for (int i = 0; i < int(min(m, k)); i++)
    vrt.insert(edges[i].second.first), vrt.insert(edges[i].second.second);
  vector<int> vertex;
  for (int x : vrt) vertex.push_back(x);
  n = (int)(vrt).size();
  vector<vector<long long>> dp(n, vector<long long>(n, INF));
  for (int i = 0; i < int(n); i++) dp[i][i] = 0;
  for (int i = 0; i < int(min(m, k)); i++) {
    int u =
        (int)(lower_bound(vertex.begin(), vertex.end(), edges[i].second.first) -
              vertex.begin());
    int v = (int)(lower_bound(vertex.begin(), vertex.end(),
                              edges[i].second.second) -
                  vertex.begin());
    dp[u][v] = dp[v][u] = min(dp[u][v], edges[i].first);
  }
  for (int l = 0; l < int(n); l++) {
    for (int i = 0; i < int(n); i++) {
      for (int j = 0; j < int(n); j++) {
        dp[i][j] = min(dp[i][j], dp[i][l] + dp[l][j]);
      }
    }
  }
  vector<long long> ans;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(i); j++) ans.push_back(dp[i][j]);
  sort(ans.begin(), ans.end());
  cout << ans[k - 1] << "\n";
  return 0;
}
