#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, i, j, z;
vector<pair<int, pair<int, int>>> a;
vector<pair<int, long long>> v[200005];
vector<int> nums;
vector<long long> ans;
long long w, d[200005];
set<pair<int, int>> st;
void dey(int x) {
  for (auto p : nums) d[p] = 1e15;
  d[x] = 0;
  st.insert({0, x});
  while (!st.empty()) {
    int u = st.begin()->second;
    st.erase(st.begin());
    for (int p = 0; p < v[u].size(); ++p) {
      int to = v[u][p].first;
      long long w = v[u][p].second;
      if (d[to] > d[u] + w) {
        st.erase({d[to], to});
        d[to] = d[u] + w;
        st.insert({d[to], to});
      }
    }
  }
}
int main() {
  cin >> n >> m >> k;
  for (i = 1; i <= m; ++i) {
    cin >> x >> y >> w;
    a.push_back({w, {x, y}});
  }
  sort(a.begin(), a.end());
  for (i = 0; i < min(m, k); ++i) {
    x = a[i].second.first;
    y = a[i].second.second;
    v[x].push_back({y, a[i].first});
    v[y].push_back({x, a[i].first});
    nums.push_back(x);
    nums.push_back(y);
  }
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
  for (j = 0; j < nums.size(); ++j) {
    dey(nums[j]);
    for (z = j + 1; z < nums.size(); ++z)
      if (d[nums[z]] != 1e15) ans.push_back(d[nums[z]]);
  }
  sort(ans.begin(), ans.end());
  cout << ans[k - 1] << "\n";
}
