#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v;
  long long c;
};
bool cmp(edge e1, edge e2) { return e1.c < e2.c; }
int n, m, K;
edge e[200005];
vector<pair<long long, int> > v[200005];
int cnt;
bool used[200005];
int idx[200005], ridx[200005];
void dfs(int now) {
  cnt++;
  idx[cnt] = now;
  ridx[now] = cnt;
  used[now] = 1;
  for (int i = 0; i < v[now].size(); i++) {
    int x = v[now][i].second;
    if (!used[x]) dfs(x);
  }
}
long long d[405][405];
vector<long long> ans;
int main() {
  cin >> n >> m >> K;
  for (int i = 0; i < m; i++) scanf("%d%d%lld", &e[i].u, &e[i].v, &e[i].c);
  sort(e, e + m, cmp);
  for (int i = 0; i < min(401, m); i++) {
    v[e[i].u].push_back(pair<long long, int>(e[i].c, e[i].v));
    v[e[i].v].push_back(pair<long long, int>(e[i].c, e[i].u));
  }
  for (int now = 1; now <= n; now++) {
    if (used[now]) continue;
    cnt = 0;
    dfs(now);
    for (int i = 1; i <= cnt; i++)
      for (int j = 1; j <= cnt; j++) d[i][j] = LLONG_MAX / 3;
    for (int i = 1; i <= cnt; i++) {
      for (int j = 0; j < v[idx[i]].size(); j++) {
        int x = ridx[v[idx[i]][j].second];
        long long cost = v[idx[i]][j].first;
        d[i][x] = cost;
      }
    }
    for (int k = 1; k <= cnt; k++)
      for (int i = 1; i <= cnt; i++)
        for (int j = 1; j <= cnt; j++)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    for (int i = 1; i <= cnt; i++) {
      for (int j = i + 1; j <= cnt; j++) ans.push_back(d[i][j]);
    }
  }
  sort(ans.begin(), ans.end());
  printf("%lld", ans[K - 1]);
  return 0;
}
