#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct edge {
  int from, to;
  long long dis;
  bool operator<(const edge &a) const { return dis < a.dis; }
} Edge[maxn];
vector<long long> vec;
long long a[805], s[805][805];
int len, n, m, k;
void floyd() {
  for (int k = 1; k <= len; k++)
    for (int i = 1; i <= len; i++)
      for (int j = 1; j <= len; j++) s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; i++)
    scanf("%d%d%lld", &Edge[i].from, &Edge[i].to, &Edge[i].dis);
  sort(Edge, Edge + m);
  for (int i = 0; i < k; i++) {
    a[len++] = Edge[i].from;
    a[len++] = Edge[i].to;
  }
  sort(a, a + len);
  len = unique(a, a + len) - a;
  for (int i = 1; i <= len; i++)
    for (int j = 1; j <= len; j++) s[i][j] = 1e16;
  int t1, t2;
  for (int i = 0; i < k; i++) {
    t1 = upper_bound(a, a + len, Edge[i].from) - a;
    t2 = upper_bound(a, a + len, Edge[i].to) - a;
    s[t1][t2] = s[t2][t1] = Edge[i].dis;
  }
  floyd();
  for (int i = 1; i <= len; i++)
    for (int j = i + 1; j <= len; j++)
      if (s[i][j] != 1e16) vec.push_back(s[i][j]);
  sort(vec.begin(), vec.end());
  printf("%lld\n", vec[k - 1]);
  return 0;
}
