#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<pair<long long, pair<long long, long long> > > g(m);
  for (long long i = 0; i < m; i++)
    cin >> g[i].second.first >> g[i].second.second >> g[i].first;
  for (long long i = 0; i < m; i++) g[i].second.first--, g[i].second.second--;
  sort(g.begin(), g.end());
  long long ver[n];
  for (long long i = 0; i < n; i++) ver[i] = 0;
  long long c = min(k, m);
  for (long long i = 0; i < c; i++)
    ver[g[i].second.first] = 1, ver[g[i].second.second] = 1;
  for (long long i = 1; i < n; i++) ver[i] += ver[i - 1];
  long long v = ver[n - 1];
  long long graph[v][v];
  for (long long i = 0; i < v; i++)
    for (long long j = 0; j < v; j++) {
      graph[i][j] = ((i == j) ? 0 : -1);
    }
  for (long long i = 0; i < c; i++)
    graph[ver[g[i].second.first] - 1][ver[g[i].second.second] - 1] =
        graph[ver[g[i].second.second] - 1][ver[g[i].second.first] - 1] =
            g[i].first;
  for (long long i = 0; i < v; i++) {
    for (long long j = 0; j < v; j++) {
      for (long long l = 0; l < v; l++) {
        if (i == j || i == l || j == l) continue;
        if (graph[j][i] != -1 && graph[i][l] != -1) {
          if (graph[j][l] == -1)
            graph[j][l] = graph[j][i] + graph[i][l];
          else
            graph[j][l] = min(graph[j][i] + graph[i][l], graph[j][l]);
        }
      }
    }
  }
  vector<long long> val;
  for (long long i = 0; i < v; i++) {
    for (long long j = i + 1; j < v; j++) {
      long long temp = graph[i][j];
      if (temp != -1) val.push_back(temp);
    }
  }
  sort(val.begin(), val.end());
  cout << val[k - 1];
}
