#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1003;
int n, m, k;
long long dp[1003][1003];
struct node {
  int x, y, z;
};
vector<pair<int, int> > g[maxn];
vector<long long> v;
bool cmp(node a, node b) { return a.z < b.z; }
int main() {
  scanf("%d%d%d", &n, &m, &k);
  vector<node> a(m);
  for (int i = 0; i < m; ++i) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
  sort(a.begin(), a.begin() + m, cmp);
  for (int i = 0; i < min(m, k); ++i) {
    v.emplace_back(a[i].x);
    v.emplace_back(a[i].y);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  memset(dp, inf, sizeof(dp));
  int t = min(m, k);
  for (int i = 0; i < t; ++i) {
    int x = lower_bound(v.begin(), v.end(), a[i].x) - v.begin();
    int y = lower_bound(v.begin(), v.end(), a[i].y) - v.begin();
    dp[x][y] = dp[y][x] = a[i].z;
  }
  int temp = v.size();
  for (int l = 0; l < temp; ++l)
    for (int j = 0; j < temp; ++j)
      if (l != j)
        for (int i = 0; i < temp; ++i)
          if (l != i && i != j)
            if (dp[i][l] + dp[l][j] < dp[i][j]) dp[i][j] = dp[i][l] + dp[l][j];
  v.clear();
  for (int i = 0; i < temp; ++i)
    for (int j = i + 1; j < temp; ++j)
      if (dp[i][j] != inf) v.emplace_back(dp[i][j]);
  sort(v.begin(), v.end());
  printf("%lld\n", v[k - 1]);
  return 0;
}
