#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const long long inf = 1e18;
vector<vector<pair<long long, long long> > > edges;
vector<bool> vis;
vector<long long> ans;
void path(int u) {
  vector<long long> dist(n, inf);
  vector<bool> reach(n, false);
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  q.push(make_pair(0, u));
  while (!q.empty()) {
    int cur = q.top().second;
    long long w = q.top().first;
    q.pop();
    if (!reach[cur]) {
      reach[cur] = true;
      dist[cur] = w;
      if (w && !vis[cur]) ans.push_back(w);
      for (int i = 0; i < (edges[cur].size()); i++) {
        int d = edges[cur][i].first;
        long long t = edges[cur][i].second;
        if (!reach[d]) {
          q.push(make_pair(t + w, d));
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  vector<vector<long long> > v(m, vector<long long>(3));
  edges = vector<vector<pair<long long, long long> > >(n);
  for (int i = 0; i < (m); i++) {
    cin >> v[i][1] >> v[i][2] >> v[i][0];
    v[i][1]--;
    v[i][2]--;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < (min(m, k)); i++) {
    int a = v[i][2];
    int b = v[i][1];
    edges[a].push_back(make_pair(b, v[i][0]));
    edges[b].push_back(make_pair(a, v[i][0]));
  }
  vis = vector<bool>(n, false);
  for (int i = 0; i < (n); i++) {
    if (edges[i].size()) {
      vis[i] = true;
      path(i);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans[k - 1] << endl;
}
