#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
template <class nmsl>
inline void read(nmsl &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
}
int n, m, k, bianshu, hd[N], nxt[N], to[N], pol;
long long cost[N];
struct abc {
  int F, T;
  long long v;
} qwq[N];
inline void addedg(int lai, int qu, long long val) {
  nxt[++bianshu] = hd[lai];
  to[bianshu] = qu;
  cost[bianshu] = val;
  hd[lai] = bianshu;
}
bool cmp(const abc &a, const abc &b) { return a.v < b.v; }
queue<int> q;
int visited[N], canreach[N];
int reach[N], cnt;
long long ans[N], dis[N];
inline void spfa(int s) {
  dis[s] = cnt = 0;
  while (q.size()) q.pop();
  q.push(s);
  while (q.size()) {
    int u = q.front();
    q.pop();
    visited[u] = 0;
    if (!canreach[u]) {
      canreach[u] = 1;
      reach[++cnt] = u;
    }
    for (register int i = hd[u]; i; i = nxt[i]) {
      if (dis[to[i]] > dis[u] + cost[i]) {
        dis[to[i]] = dis[u] + cost[i];
        if (!visited[to[i]]) {
          visited[to[i]] = 1;
          q.push(to[i]);
        }
      }
    }
  }
  for (register int i = 1; i <= cnt; i++) {
    if (reach[i] > s) ans[++pol] = dis[reach[i]];
    canreach[reach[i]] = 0;
    dis[reach[i]] = 2e9 * 400;
  }
  return;
}
int main() {
  read(n), read(m), read(k);
  for (register int i = 1; i <= m; i++)
    read(qwq[i].F), read(qwq[i].T), read(qwq[i].v);
  sort(qwq + 1, qwq + 1 + m, cmp);
  for (register int i = 1; i <= min(k, m); i++)
    addedg(qwq[i].F, qwq[i].T, qwq[i].v), addedg(qwq[i].T, qwq[i].F, qwq[i].v);
  for (register int i = 1; i <= n; i++) dis[i] = 2e9 * 400;
  for (register int i = 1; i <= n; i++) {
    spfa(i);
  }
  sort(ans + 1, ans + 1 + pol);
  cout << ans[k];
  return 0;
}
