#include <bits/stdc++.h>
using namespace std;
const int maxn = (2e5) + 5;
const int inf = 1e9;
int n;
int m;
vector<pair<int, int> > edges[maxn];
int k;
map<int, bool> inqueue;
map<int, long long> dist;
struct Edge {
  int u, v;
  long long d;
  Edge(int uu, int vv, long long dd) {
    u = uu;
    v = vv;
    d = dd;
  }
};
bool operator<(Edge a, Edge b) { return a.d < b.d; }
vector<Edge> adj;
set<int> vers;
int main() {
  cin >> n >> m >> k;
  for (int i = (int)1; i <= (int)m; i++) {
    int u, v;
    long long d;
    cin >> u >> v >> d;
    adj.push_back(Edge(u, v, d));
  }
  sort((adj).begin(), (adj).end());
  for (int i = (int)0; i <= (int)min(m, k) - 1; i++) {
    int u = adj[i].u;
    int v = adj[i].v;
    long long d = adj[i].d;
    vers.insert(u);
    vers.insert(v);
    edges[u].push_back({d, v});
    edges[v].push_back({d, u});
  }
  queue<int> q;
  vector<long long> ans;
  for (auto s : vers) {
    inqueue.clear();
    dist.clear();
    dist[s] = 0;
    q.push(s);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      inqueue[u] = false;
      for (auto it : edges[u]) {
        int v = it.second;
        long long d = it.first;
        if (!dist.count(v) || dist[v] > dist[u] + d) {
          dist[v] = dist[u] + d;
          if (!inqueue.count(v) || !inqueue[v]) {
            inqueue[v] = true;
            q.push(v);
          }
        }
      }
    }
    for (auto it : dist) {
      if (it.first == s) continue;
      ans.push_back(it.second);
    }
  }
  sort((ans).begin(), (ans).end());
  cout << ans[2 * k - 1] << endl;
}
