#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a, b, w;
vector<pair<int, int>> adj[200005];
bool can(long long x) {
  int cnt = 0;
  vector<int> vis(n + 1);
  for (int i = 1; i <= n; i++) {
    priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                   greater<pair<long long, int>>>
        nxt;
    nxt.push(make_pair(0, i));
    while (!nxt.empty()) {
      auto c = nxt.top();
      nxt.pop();
      if (vis[c.second] == i) continue;
      vis[c.second] = i, cnt += (c.second != i);
      if (cnt == k) return 0;
      for (auto& e : adj[c.second])
        if (c.first + e.first <= x && vis[e.second] != i)
          nxt.push({c.first + e.first, e.second});
    }
  }
  return 1;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  k *= 2;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &w);
    adj[a].emplace_back(w, b);
    adj[b].emplace_back(w, a);
  }
  long long st = 1, en = 4e11, mid;
  while (st <= en) {
    mid = (st + en) >> 1;
    if (!can(mid))
      en = mid - 1;
    else
      st = mid + 1;
  }
  printf("%I64d\n", st);
}
