#include <bits/stdc++.h>
using namespace std;
int findIdx(const vector<long long> &verts, long long v) {
  for (int i = 0; i < verts.size(); i++) {
    if (verts[i] == v) return i;
  }
  return -1;
}
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<pair<long long, pair<long long, long long>>> edges(m);
  for (int i = 0; i < m; i++) {
    cin >> edges[i].second.first >> edges[i].second.second >> edges[i].first;
  }
  sort(edges.begin(), edges.end());
  vector<long long> verts;
  for (int i = 0; i < min(m, k); i++) {
    long long u = edges[i].second.first, v = edges[i].second.second;
    verts.push_back(u);
    verts.push_back(v);
  }
  verts.erase(unique(verts.begin(), verts.end()), verts.end());
  long long INF = 1e17;
  n = verts.size();
  vector<vector<long long>> dp(n, vector<long long>(n, INF));
  for (int i = 0; i < min(m, k); i++) {
    long long u = edges[i].second.first, v = edges[i].second.second,
              w = edges[i].first;
    long long uIdx = findIdx(verts, u), vIdx = findIdx(verts, v);
    dp[uIdx][vIdx] = w;
    dp[vIdx][uIdx] = w;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dp[i][k] + dp[k][j] < dp[i][j]) dp[i][j] = dp[i][k] + dp[k][j];
      }
    }
  }
  vector<long long> mat;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      mat.push_back(dp[i][j]);
    }
  }
  sort(mat.begin(), mat.end());
  cout << mat[k - 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) solve();
  return 0;
}
