#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct three {
  int u, v, w;
  bool operator<(const three &other) const { return w < other.w; }
};
int n, m, k;
long long w[805][805];
vector<three> e;
vector<int> node;
void gogo() {
  cin >> n >> m >> k;
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    e.push_back({u, v, w});
  }
  sort((e).begin(), (e).end());
  for (int i = 0; i <= 800; ++i)
    for (int j = 0; j <= 800; ++j)
      if (i != j) {
        w[i][j] = 1e15;
      }
  for (int i = 0; i < min(((int)(e).size()), k); ++i) {
    node.push_back(e[i].u);
    node.push_back(e[i].v);
  }
  sort((node).begin(), (node).end());
  node.resize(unique((node).begin(), (node).end()) - node.begin());
  for (int i = 0; i < min(((int)(e).size()), k); ++i) {
    int u =
        lower_bound((node).begin(), (node).end(), e[i].u) - node.begin() + 1;
    int v =
        lower_bound((node).begin(), (node).end(), e[i].v) - node.begin() + 1;
    w[u][v] = min(w[u][v], (long long)e[i].w);
    w[v][u] = min(w[v][u], (long long)e[i].w);
  }
  for (int k = 1; k <= ((int)(node).size()); ++k) {
    for (int i = 1; i <= ((int)(node).size()); ++i) {
      for (int j = 1; j <= ((int)(node).size()); ++j) {
        w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
      }
    }
  }
  vector<long long> ans;
  for (int i = 1; i <= ((int)(node).size()); ++i)
    for (int j = i + 1; j <= ((int)(node).size()); ++j) {
      if (i != j) ans.push_back(w[i][j]);
    }
  sort((ans).begin(), (ans).end());
  cout << ans[k - 1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("sol"
            ".inp",
            "r")) {
    freopen(
        "sol"
        ".inp",
        "r", stdin);
    freopen(
        "sol"
        ".out",
        "w", stdout);
  }
  gogo();
}
