#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxn = 200000 + 10;   int n, m, k, nv;   vector<pair<int, pair<int, int> > > edge;   vector<pair<int, int> > e[maxn];   int f[maxn];   bool vis[maxn];   long long dis[maxn];   vector<long long> q;   void print(int a[], int n, int st = 0) {     for (int i = 0; i < n; i++) {       if (i != 0) printf(   );       printf( %d , a[i + st]);     }     printf(  n );   }   void init() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < m; i++) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       edge.push_back(make_pair(w, make_pair(min(u, v), max(u, v))));     }   }   void doit() {     sort(edge.begin(), edge.end());     memset(f, -1, sizeof(f));     nv = 0;     for (int i = 0; i < min(k, m); i++) {       int u = edge[i].second.first, v = edge[i].second.second, w = edge[i].first;       if (f[u] == -1) f[u] = nv++;       u = f[u];       if (f[v] == -1) f[v] = nv++;       v = f[v];       e[u].push_back(make_pair(v, w));       e[v].push_back(make_pair(u, w));     }     for (int st = 0; st < nv; st++) {       for (int i = 0; i < nv; i++) vis[i] = false;       vis[st] = true;       for (int i = 0; i < nv; i++) dis[i] = -1;       dis[st] = 0;       int cur = st;       while (1) {         for (int i = 0; i < e[cur].size(); i++) {           int v = e[cur][i].first, w = e[cur][i].second;           if (!vis[v] && (dis[v] == -1 || dis[v] > dis[cur] + w)) {             dis[v] = dis[cur] + w;           }         }         long long mn = -1;         for (int i = 0; i < nv; i++) {           if (!vis[i] && (dis[i] != -1 && (mn == -1 || dis[i] < mn))) {             mn = dis[i];             cur = i;           }         }         if (vis[cur]) break;         vis[cur] = true;       }       for (int i = st + 1; i < nv; i++) {         if (vis[i]) q.push_back(dis[i]);       }     }     sort(q.begin(), q.end());     printf( %lld n , q[k - 1]);   }   int main() {     init();     doit();     return 0;   }   