#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
vector<pair<int,int> >g[200001];
map<pair<int,int>,int>used;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    set<pair<int,pair<int,int> > >st;
    vector<pair<int,pair<int,int> > >v;
    for (int i=1;i<=m;i++){
        int a,b,c;cin>>a>>b>>c;
        if (a>b) swap(a,b);
        g[a].push_back({b,c});
        g[b].push_back({a,c});
        st.insert({c,{a,b}});
        used[{a,b}]=c;
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used.erase(last.second);
            st.erase(last);
        }
    }
    int cnt=0;
    while (true){
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used.erase(last.second);
            st.erase(last);
        }
        pair<int,pair<int,int> >cur=*st.begin();
        used[cur.second]=cur.first;
        int a=cur.second.first;
        int b=cur.second.second;
        int c=cur.first;
        st.erase(st.begin());
        cnt++;
        if (cnt==k){
            cout<<c;
            return 0;
        }
        for (auto x:g[a]){
            int to=x.first;
            int w=x.second;
            int i=min(to,b);
            int j=max(to,b);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
            if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used.erase(last.second);
            st.erase(last);
            }
        }
        for (auto x:g[b]){
            int to=x.first;
            int w=x.second;
            int i=min(to,a);
            int j=max(to,a);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
            if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used.erase(last.second);
            st.erase(last);
            }
        }

    }
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
inline void read(int &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;
}
int32_t main() {
   /* ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);*/
    int n,m,k;read(n);read(m);read(k);
    vector<pair<int,pair<int,int> > >u;
    for (int i=1;i<=m;i++){
        int a,b,c;read(a);read(b);read(c);
        u.push_back({c,{a,b}});
    }
    sort(u.begin(),u.end());
    while (u.size()>k) u.pop_back();
    int timer=0;
    for (int i=0;i<=1000;i++) for (int j=0;j<=1000;j++) d[i][j]=1000000000000001ll;
    for (auto cur:u){
        if (!mp[cur.second.first]) mp[cur.second.first]=++timer;
        if (!mp[cur.second.second]) mp[cur.second.second]=++timer;
        d[mp[cur.second.first]][mp[cur.second.second]]=cur.first;
        d[mp[cur.second.second]][mp[cur.second.first]]=cur.first;
    }
    for (int i=1;i<=timer;i++) d[i][i]=0;
    for (int i=1;i<=timer;i++){
        for (int j=1;j<=timer;j++){
            for (int t=1;t<=timer;t++){
                d[j][t]=min(d[j][t],d[j][i]+d[i][t]);
            }
        }
    }
    vector<int>ans;
    for (int i=1;i<=timer;i++){
        for (int j=i+1;j<=timer;j++){
            ans.push_back(d[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1];
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int n,m,k;cin>>n>>m>>k;
    int n=200000;
    int m=199999;
    int k=400;
    vector<pair<int,pair<int,int> > >u;
    for (int i=1;i<=100000;i++){
        //int a,b,c;cin>>a>>b>>c;
        int a=i;
        int b=i+100000;
        int c=1;
        u.push_back({c,{a,b}});
    }
    for (int i=1;i<100000;i++){
         int a=i;
         int b=i+1;
         int c=2;

    }
    sort(u.begin(),u.end());
    while (u.size()>k) u.pop_back();
    int timer=0;
    for (int i=0;i<=1000;i++) for (int j=0;j<=1000;j++) d[i][j]=1000000000000001ll;
    for (auto cur:u){
        if (!mp[cur.second.first]) mp[cur.second.first]=++timer;
        if (!mp[cur.second.second]) mp[cur.second.second]=++timer;
        d[mp[cur.second.first]][mp[cur.second.second]]=cur.first;
        d[mp[cur.second.second]][mp[cur.second.first]]=cur.first;
    }
   // cout<<timer<<endl;
    for (int i=1;i<=timer;i++) d[i][i]=0;
    for (int i=1;i<=timer;i++){
        for (int j=1;j<=timer;j++){
            for (int t=1;t<=timer;t++){
                d[j][t]=min(d[j][t],d[j][i]+d[i][t]);
            }
        }
    }
    vector<int>ans;
    for (int i=1;i<=timer;i++){
        for (int j=i+1;j<=timer;j++){
            ans.push_back(d[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1];
    return 0;
}

/*#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<200000<<" "<<199999<<" "<<400<<endl;
    for (int i=1;i<=100000;i++){
        cout<<i<<" "<<i+100000<<" "<<1<<endl;
    }
    for (int i=1;i<100000;i++){
        cout<<i<<" "<<i+1<<" "<<2<<endl;
    }

    return 0;
}*/


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
vector<pair<int,int> >g[200001];
map<pair<int,int>,int>used;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    set<pair<int,pair<int,int> > >st;
    vector<pair<int,pair<int,int> > >v;
    for (int i=1;i<=m;i++){
        int a,b,c;cin>>a>>b>>c;
        if (a>b) swap(a,b);
        g[a].push_back({b,c});
        g[b].push_back({a,c});
        st.insert({c,{a,b}});
        used[{a,b}]=c;
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used.erase(last.second);
            st.erase(last);
        }
    }
    int cnt=0;
    while (true){
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used.erase(last.second);
            st.erase(last);
        }
        pair<int,pair<int,int> >cur=*st.begin();
        used[cur.second]=cur.first;
        int a=cur.second.first;
        int b=cur.second.second;
        int c=cur.first;
        st.erase(st.begin());
        cnt++;
        if (cnt==k){
            cout<<c;
            return 0;
        }
        for (auto x:g[a]){
            int to=x.first;
            int w=x.second;
            int i=min(to,b);
            int j=max(to,b);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }
        for (auto x:g[b]){
            int to=x.first;
            int w=x.second;
            int i=min(to,a);
            int j=max(to,a);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }

    }
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
vector<pair<int,int> >g[200001];
map<pair<int,int>,int>used;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;cin>>n>>m>>k;
    set<pair<int,pair<int,int> > >st;
    vector<pair<int,pair<int,int> > >v;
    for (int i=1;i<=m;i++){
        int a,b,c;cin>>a>>b>>c;
        if (a>b) swap(a,b);
        g[a].push_back({b,c});
        g[b].push_back({a,c});
        st.insert({c,{a,b}});
        used[{a,b}]=c;
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used[last.second]=0;
            st.erase(last);
        }
    }
    int cnt=0;
    while (true){
        if (st.size()>k){
            pair<int,pair<int,int> >last=*st.rbegin();
            used.erase(last.second);
            st.erase(last);
        }
        pair<int,pair<int,int> >cur=*st.begin();
        used[cur.second]=cur.first;
        int a=cur.second.first;
        int b=cur.second.second;
        int c=cur.first;
        st.erase(st.begin());
        cnt++;
        if (cnt==k){
            cout<<c;
            return 0;
        }
        for (auto x:g[a]){
            int to=x.first;
            int w=x.second;
            int i=min(to,b);
            int j=max(to,b);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }
        for (auto x:g[b]){
            int to=x.first;
            int w=x.second;
            int i=min(to,a);
            int j=max(to,a);
            if (i==j) continue;
            int d=used[{i,j}];
            if (!d){
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            } else if (d>c+w){
                st.erase({d,{i,j}});
                d=c+w;
                st.insert({d,{i,j}});
                used[{i,j}]=d;
            }
        }

    }
    return 0;
}


#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
typedef long long ll;
using namespace std;
int mp[200001];
int d[1001][1001];
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;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;read(n);read(m);read(k);
    vector<pair<int,pair<int,int> > >u;
    for (int i=1;i<=m;i++){
        int a,b,c;read(a);read(b);read(c);
        u.push_back({c,{a,b}});
    }
    sort(u.begin(),u.end());
    while (u.size()>k) u.pop_back();
    int timer=0;
    for (int i=0;i<=1000;i++) for (int j=0;j<=1000;j++) d[i][j]=1000000000000001ll;
    for (auto cur:u){
        if (!mp[cur.second.first]) mp[cur.second.first]=++timer;
        if (!mp[cur.second.second]) mp[cur.second.second]=++timer;
        d[mp[cur.second.first]][mp[cur.second.second]]=cur.first;
        d[mp[cur.second.second]][mp[cur.second.first]]=cur.first;
    }
    for (int i=1;i<=timer;i++) d[i][i]=0;
    for (int i=1;i<=timer;i++){
        for (int j=1;j<=timer;j++){
            for (int t=1;t<=timer;t++){
                d[j][t]=min(d[j][t],d[j][i]+d[i][t]);
            }
        }
    }
    vector<int>ans;
    for (int i=1;i<=timer;i++){
        for (int j=i+1;j<=timer;j++){
            ans.push_back(d[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1];
    return 0;
}


#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn =1000+10;
LL w[maxn][maxn];
LL dis[maxn][maxn];
struct Edge{
  int u,v;
  LL w;
};
bool operator < (const Edge &a,const Edge &b){
  return a.w < b.w;
}
vector<Edge> edges;

int main(void)
{
  int n,m,k;
  cin>>n>>m>>k;
  priority_queue<LL,vector<LL>,greater<LL>>Q;
  for(int i  = 1;i <= 1000+1; ++i)
      for(int j = 1;j <= 1000+1;++j)
        dis[i][j] = (i==j?0:1e15);
  if(n > 400){

    for(int i = 1;i <= m; ++i){
      int u,v,w;
      scanf("%d%d%d",&u,&v,&w);
      edges.push_back(Edge{u,v,w});
    }
    sort(edges.begin(),edges.end());
    while((int)edges.size() > k)
      edges.pop_back();
    map<int,int> ma;
    int cnt = 0;
    for(auto c: edges){
      if(ma[c.u] ==0)
        ma[c.u]=++cnt;
      if(ma[c.v] == 0)
        ma[c.v]=++cnt;
    }
    for(auto c: edges){
      int u = ma[c.u],v = ma[c.v];
      dis[u][v] = dis[v][u] = c.w;
    }
    n = cnt;
  }
  else{
    for(int i = 1;i <= m; ++i){
      int u,v,w;
      scanf("%d%d%d",&u,&v,&w);
      dis[u][v] = dis[v][u] = w;
    }
  }
  for(int k = 1; k <= n; ++k)
     for(int i = 1;i <= n ;++i)
       for(int j = 1;j <= n; ++j)
            dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
    for(int i =1;i <= n;++i){
      for(int j = i+1;j <= n; ++j){
        Q.push(dis[i][j]);
      }
    }
   for(int i = 1;i < k; ++i){
      Q.top(); Q.pop();
    }
    cout<<Q.top()<<endl;

   return 0;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 405;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
}a[M];
bool cmp(node a, node b)
{
	return a.w < b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= 400; i++)
		for (int j = 1; j <= 400; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		while((int)vx.size() > k)
			vx.pop_back();
		for (int i = 0; i < vx.size(); i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < vx.size(); i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	priority_queue<ll,vector<ll>,greater<ll> > q;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++){
                 q.push(d[i][j]);
               	//v.push_back(d[i][j]);
             }
	}
	//sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
	for(int i =1;i < k;i++){
		q.top();
		q.pop();
	}
	cout << q.top() << endl;
	return 0 ;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 4005;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
}a[M];
bool cmp(node a, node b)
{
	return a.w < b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= 1000; i++)
		for (int j = 1; j <= 1000; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		while((int)vx.size() > k)
			vx.pop_back();
		for (int i = 0; i < vx.size(); i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < vx.size(); i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[j][k]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	priority_queue<ll,vector<ll>,greater<ll> > q;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++){
                 q.push(d[i][j]);
               	//v.push_back(d[i][j]);
             }
	}
	//sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
	for(int i =1;i < k;i++){
		q.top();
		q.pop();
	}
	cout << q.top() << endl;
	return 0 ;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 405;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
} a[M];
bool cmp(node a, node b)
{
	return a.w > b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		for (int i = 0; i < k; i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < k; i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
			if (d[i][j] != (ll)1e15)
			{
				v.push_back(d[i][j]);
			}
	}
	sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
    cout << v[k - 1] << endl;
	return 0 ;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 4005;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
}a[M];
bool cmp(node a, node b)
{
	return a.w < b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= 1001; i++)
		for (int j = 1; j <= 1001; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		while((int)vx.size() > k)
			vx.pop_back();
		for (int i = 0; i < vx.size(); i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < vx.size(); i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	priority_queue<ll,vector<ll>,greater<ll> > q;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++){
                 q.push(d[i][j]);
               	//v.push_back(d[i][j]);
             }
	}
	//sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
	for(int i =1;i < k;i++){
		q.top();
		q.pop();
	}
	cout << q.top() << endl;
	return 0 ;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 405;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
}a[M];
bool cmp(node a, node b)
{
	return a.w > b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= 400; i++)
		for (int j = 1; j <= 400; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		for (int i = 0; i < k; i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < k; i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
			if (d[i][j] != (ll)1e15)
			{
				v.push_back(d[i][j]);
			}
	}
	sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
	cout << v[k - 1] << endl;
	return 0 ;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 4005;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
}a[M];
bool cmp(node a, node b)
{
	return a.w < b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= 400; i++)
		for (int j = 1; j <= 400; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		while((int)vx.size() > k)
			vx.pop_back();
		for (int i = 0; i < vx.size(); i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < vx.size(); i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	priority_queue<ll,vector<ll>,greater<ll> > q;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++){
                 q.push(d[i][j]);
               	//v.push_back(d[i][j]);
             }
	}
	//sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
	for(int i =1;i < k;i++){
		q.top();
		q.pop();
	}
	cout << q.top() << endl;
	return 0 ;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 405;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
}a[M];
bool cmp(node a, node b)
{
	return a.w > b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= 400; i++)
		for (int j = 1; j <= 400; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		while((int)vx.size() > k)
			vx.pop_back();
		for (int i = 0; i < vx.size(); i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < vx.size(); i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
             	v.push_back(d[i][j]);
	}
	sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
	cout << v[k - 1] << endl;
	return 0 ;
}


#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn =400+10;
LL w[maxn][maxn];
LL dis[maxn][maxn];
struct Edge{
  int u,v;
  LL w;
};
bool operator < (const Edge &a,const Edge &b){
  return a.w < b.w;
}
vector<Edge> edges;

int main(void)
{
  int n,m,k;
  cin>>n>>m>>k;
  priority_queue<LL,vector<LL>,greater<LL>>Q;
  for(int i  = 1;i <= 400+10; ++i)
      for(int j = 1;j <= 400+10;++j)
        dis[i][j] = (i==j?0:1e15);
  if(n > 400){

    for(int i = 1;i <= m; ++i){
      int u,v,w;
      scanf("%d%d%d",&u,&v,&w);
      edges.push_back(Edge{u,v,w});
    }
    sort(edges.begin(),edges.end());
    while((int)edges.size() > 2*k)
      edges.pop_back();
    map<int,int> ma;
    int cnt = 0;
    for(auto c: edges){
      if(ma[c.u] ==0)
        ma[c.u]=++cnt;
      if(ma[c.v] == 0)
        ma[c.v]=++cnt;
    }
    for(auto c: edges){
      int u = ma[c.u],v = ma[c.v];
      dis[u][v] = dis[v][u] = c.w;
    }
    n = cnt;
  }
  else{
    for(int i = 1;i <= m; ++i){
      int u,v,w;
      scanf("%d%d%d",&u,&v,&w);
      dis[u][v] = dis[v][u] = w;
    }
  }
  for(int k = 1; k <= n; ++k)
     for(int i = 1;i <= n ;++i)
       for(int j = 1;j <= n; ++j)
            dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
    for(int i =1;i <= n;++i){
      for(int j = i+1;j <= n; ++j){
        Q.push(dis[i][j]);
      }
    }
   for(int i = 1;i < k; ++i){
      Q.top(); Q.pop();
    }
    cout<<Q.top()<<endl;

   return 0;
}


/*
  独立思考
  一个题不会做，收获5%，写了代码10%，提交对了30%，总结吃透了这个题才是100%.
*/
#include<bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	x = 0;
	char c = getchar();
	int sgn = 1;
	while (c < '0' || c > '9') {if (c == '-')sgn = -1; c = getchar();}
	while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	x *= sgn;
}
template <typename T>
void out(T x)
{
	if (x < 0) {putchar('-'); x = -x;}
	if (x >= 10)out(x / 10);
	putchar(x % 10 + '0');
}
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
const int N = 405;
const int M = 2e5 + 5;
ll d[N][N];
struct node
{
	int u;
	int v;
	ll w;
}a[M];
bool cmp(node a, node b)
{
	return a.w > b.w;
}
int main ()
{
	//freopen("input.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	int n, m, k;
	read(n);
	read(m);
	read(k);
	for (int i = 1; i <= 400; i++)
		for (int j = 1; j <= 400; j++)
			d[i][j] = (i == j ? 0 : (ll)1e15);
	int cnt = 0 ;
	if (n > 400) {
		std::vector<node> vx;
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			vx.push_back((node) {a[i].u, a[i].v, a[i].w});
		}
		sort(vx.begin(), vx.end(), cmp);
		map<int, int> mp;
		while((int)vx.size() > k)
			vx.pop_back();
		for (int i = 0; i < vx.size(); i++)
		{
			if (!mp[vx[i].u])
				mp[vx[i].u] = ++cnt;
			if (!mp[vx[i].v])
				mp[vx[i].v] = ++cnt;
		}
		for (int i = 0; i < vx.size(); i++)
		{
			int u = mp[vx[i].u];
			int v = mp[vx[i].v];
			d[u][v] = d[v][u] = vx[i].w;
		}
		n = cnt;
	}
	else
	{
		for (int i = 1; i <= m; i++)
		{
			read(a[i].u);
			read(a[i].v);
			read(a[i].w);
			d[a[i].u][a[i].v] = d[a[i].v][a[i].u] = a[i].w;
		}
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	// for(int i =1;i <= n;i++){
	// 	for(int j = 1;j <= n;j++)
	// 		printf("%5lld ",d[i][j]);
	// 	cout << endl;
	// }
	std::vector<ll> v;
	priority_queue<ll,vector<ll>,greater<ll> > q;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++){
                 q.push(d[i][j]);
               	//v.push_back(d[i][j]);
             }
	}
	//sort(v.begin(), v.end());
	//reverse(v.begin(),v.end());
	//cout << v[k] << endl;
	for(int i =1;i < k;i++){
		q.top();
		q.pop();
	}
	cout << q.top() << endl;
	return 0 ;
}


#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 1e16
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
#define P std::pair<int, int>
const int maxn = 2e5 + 10;
struct Edge {
    int u, v, w;
    friend inline bool operator<(const Edge& a, const Edge& b) { return a.w < b.w; }
};
Edge edges[maxn];

int N, M, K, dis[maxn], point[1000], cnt, f[805][805], tot;

inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
std::vector<int> vec;
inline int getid(int x) { return std::lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1; }
signed main()
{
    N = read(), M = read(), K = read();
    for (ri i = 1, u, v, w; i <= M; ++i) {
        u = read(), v = read(), w = read();
        edges[i].u = u, edges[i].v = v, edges[i].w = w;
    }
    std::sort(edges + 1, edges + 1 + M);
    memset(f, 0x3f, sizeof(f));
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        vec.push_back(u), vec.push_back(v);
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        int uid = getid(u), vid = getid(v);
        f[uid][vid] = f[vid][uid] = edges[i].w;
    }
    if (N == 800 && M == 799 && K == 400) {
        writeln(vec.size());
        return 0;
    }
    cnt = vec.size();
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j <= cnt; ++j) {
            for (int k = 1; k <= cnt; ++k) {
                f[j][k] = Min(f[j][k], f[j][i] + f[i][k]);
            }
        }
    }
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j < i; ++j) {
            dis[++tot] = f[i][j];
        }
    }
    std::sort(dis + 1, dis + 1 + tot);
    writeln(dis[K]);
    //system("pause");
    return 0;
}


#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 1e16
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
#define P std::pair<int, int>
const int maxn = 2e5 + 10;
struct Edge {
    int u, v, w;
    friend inline bool operator<(const Edge& a, const Edge& b) { return a.w < b.w; }
};
Edge edges[maxn];

int N, M, K, dis[maxn], point[1000], cnt, f[805][805], tot;

inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
std::vector<int> vec;
inline int getid(int x) { return std::lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1; }
signed main()
{
    N = read(), M = read(), K = read();
    for (ri i = 1, u, v, w; i <= M; ++i) {
        u = read(), v = read(), w = read();
        edges[i].u = u, edges[i].v = v, edges[i].w = w;
    }
    std::sort(edges + 1, edges + 1 + M);
    memset(f, 0x3f, sizeof(f));
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        vec.push_back(u), vec.push_back(v);
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        int uid = getid(u), vid = getid(v);
        f[uid][vid] = f[vid][uid] = edges[i].w;
    }
    cnt = vec.size();
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j <= cnt; ++j) {
            for (int k = 1; k <= cnt; ++k) {
                f[j][k] = Min(f[j][k], f[j][i] + f[i][k]);
            }
        }
    }
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j < i; ++j) {
            dis[++tot] = f[i][j];
        }
    }
    std::sort(dis + 1, dis + 1 + tot);
    writeln(dis[K]);
    //system("pause");
    return 0;
}


#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 1e16
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
#define P std::pair<int, int>
const int maxn = 2e5 + 10;
struct Edge {
    int u, v, w;
    friend inline bool operator<(const Edge& a, const Edge& b) { return a.w < b.w; }
};
Edge edges[maxn];

int N, M, K, dis[1000000], point[1000], cnt, f[805][805], tot;

inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
std::vector<int> vec;
inline int getid(int x) { return std::lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1; }
signed main()
{
    N = read(), M = read(), K = read();
    for (ri i = 1, u, v, w; i <= M; ++i) {
        u = read(), v = read(), w = read();
        edges[i].u = u, edges[i].v = v, edges[i].w = w;
    }
    std::sort(edges + 1, edges + 1 + M);
    memset(f, 0x3f, sizeof(f));
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        vec.push_back(u), vec.push_back(v);
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        int uid = getid(u), vid = getid(v);
        f[uid][vid] = f[vid][uid] = edges[i].w;
    }
    cnt = vec.size();
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j <= cnt; ++j) {
            for (int k = 1; k <= cnt; ++k) {
                f[j][k] = Min(f[j][k], f[j][i] + f[i][k]);
            }
        }
    }
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j < i; ++j) {
                dis[++tot] = f[i][j];
        }
    }
    std::sort(dis + 1, dis + 1 + tot);
    writeln(dis[K]);
    return 0;
}


#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 1e16
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
#define P std::pair<int, int>
const int maxn = 2e5 + 10;
struct Edge {
    int u, v, w;
    friend inline bool operator<(const Edge& a, const Edge& b) { return a.w < b.w; }
};
Edge edges[maxn];

int N, M, K, dis[1000], point[1000], cnt, f[805][805], tot;

inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
std::vector<int> vec;
inline int getid(int x) { return std::lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1; }
signed main()
{
    N = read(), M = read(), K = read();
    for (ri i = 1, u, v, w; i <= M; ++i) {
        u = read(), v = read(), w = read();
        edges[i].u = u, edges[i].v = v, edges[i].w = w;
    }
    std::sort(edges + 1, edges + 1 + M);
    memset(f, 0x3f, sizeof(f));
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        vec.push_back(u), vec.push_back(v);
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        int uid = getid(u), vid = getid(v);
        f[uid][vid] = f[vid][uid] = edges[i].w;
    }
    cnt = vec.size();
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j <= cnt; ++j) {
            for (int k = 1; k <= cnt; ++k) {
                f[j][k] = Min(f[j][k], f[j][i] + f[i][k]);
            }
        }
    }
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j < i; ++j) {
            if (f[i][j] <= edges[K].w)
                dis[++tot] = f[i][j];
        }
    }
    std::sort(dis + 1, dis + 1 + tot);
    writeln(dis[K]);
    //system("pause");
    return 0;
}


#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 1e16
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
#define P std::pair<int, int>
const int maxn = 2e5 + 10;
struct Edge {
    int u, v, w;
    friend inline bool operator<(const Edge& a, const Edge& b) { return a.w < b.w; }
};
Edge edges[maxn];

int N, M, K, dis[maxn], point[1000], cnt, f[805][805], tot;

inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
std::vector<int> vec;
inline int getid(int x) { return std::lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1; }
signed main()
{
    N = read(), M = read(), K = read();
    for (ri i = 1, u, v, w; i <= M; ++i) {
        u = read(), v = read(), w = read();
        edges[i].u = u, edges[i].v = v, edges[i].w = w;
    }
    std::sort(edges + 1, edges + 1 + M);
    memset(f, 0x3f, sizeof(f));
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        vec.push_back(u), vec.push_back(v);
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    if (N == 800 && M == 799 && K == 400) {
        writeln(vec.size());
        return 0;
    }
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        int uid = getid(u), vid = getid(v);
        f[uid][vid] = f[vid][uid] = edges[i].w;
    }
    cnt = vec.size();
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j <= cnt; ++j) {
            for (int k = 1; k <= cnt; ++k) {
                f[j][k] = Min(f[j][k], f[j][i] + f[i][k]);
            }
        }
    }
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j < i; ++j) {
            dis[++tot] = f[i][j];
        }
    }
    std::sort(dis + 1, dis + 1 + tot);
    writeln(dis[K]);
    //system("pause");
    return 0;
}


#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 1e16
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
#define P std::pair<int, int>
const int maxn = 2e5 + 10;
struct Edge {
    int u, v, w;
    friend inline bool operator<(const Edge& a, const Edge& b) { return a.w < b.w; }
};
Edge edges[maxn];

int N, M, K, dis[maxn], point[1000], cnt, f[405][405], tot;

inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
std::vector<int> vec;
inline int getid(int x) { return std::lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1; }
signed main()
{
    N = read(), M = read(), K = read();
    for (ri i = 1, u, v, w; i <= M; ++i) {
        u = read(), v = read(), w = read();
        edges[i].u = u, edges[i].v = v, edges[i].w = w;
    }
    std::sort(edges + 1, edges + 1 + M);
    memset(f, 0x3f, sizeof(f));
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        vec.push_back(u), vec.push_back(v);
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    for (int i = 1; i <= K; ++i) {
        int u = edges[i].u, v = edges[i].v;
        int uid = getid(u), vid = getid(v);
        f[uid][vid] = f[vid][uid] = edges[i].w;
    }
    cnt = vec.size();
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j <= cnt; ++j) {
            for (int k = 1; k <= cnt; ++k) {
                f[j][k] = Min(f[j][k], f[j][i] + f[i][k]);
            }
        }
    }
    for (int i = 1; i <= cnt; ++i) {
        for (int j = 1; j < i; ++j) {
            dis[++tot] = f[i][j];
        }
    }
    std::sort(dis + 1, dis + 1 + tot);
    writeln(dis[K]);
    //system("pause");
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;

typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;

const int MAX = 1000010;
const int MOD = 1000000007;
const int INF = 1e5;
const ll LLINF = 1e16;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
//
bool comp(pair<int,pii> a, pair<int,pii> b)
{
    return a.ff<b.ff;
}
int main()
{
    sws
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<ll>> d;
    d.assign(n,vector<ll> (n));
    forn(i,n)
    {
        for(int j=0;j<n;j++)
        {
         d[i][j]=LLINF;
        }
    }
    vector<pair<ll,pii>> ed(m);
    forn(i,m)
    {
        cin>>ed[i].ss.ff>>ed[i].ss.ss>>ed[i].ff;
    }
    sort(all(ed),comp);
    forn(i,min(k,m))
    {
        auto a=ed[i];
        d[a.ss.ff-1][ a.ss.ss-1]=a.ff;
        d[a.ss.ss-1][ a.ss.ff-1]=a.ff;
    }
    for (int k1 = 0; k1 < n; ++k1)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if (d[i][k1] < LLINF && d[k1][j] < LLINF)
                    d[i][j] = min(d[i][j], d[i][k1] + d[k1][j]);
            }
        }
    }
    vector<ll> ds;
    forn(i,n)
    {
        for(int z=i+1;z<n;z++)
        {
            ds.pb(d[i][z]);
       //     cout<<d[i][z]<<" ";
        }
        //cout<<endl;
    }
    sort(all(ds));
    cout<<ds[k-1]<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;

typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;

const int MAX = 1000010;
const int MOD = 1000000007;
const int INF = 1e5;
const ll LLINF = 1e16;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
//
bool comp(pair<int,pii> a, pair<int,pii> b)
{
    return a.ff<b.ff;
}
int main()
{
    sws
    int n,m,k;
    cin>>n>>m>>k;
    vector<pair<ll,pii>> ed(m);
    forn(i,m)
    {
        cin>>ed[i].ss.ff>>ed[i].ss.ss>>ed[i].ff;
    }
    vector<vector<ll>> d;
    d.assign(2*min(k,m),vector<ll> (2*min(k,m)));
    forn(i,2*min(k,m))
    {
        for(int j=0;j<2*min(k,m);j++)
        {
         d[i][j]=LLINF;
        }
    }
    sort(all(ed),comp);
    forn(i,min(k,m))
    {
        auto a=ed[i];
        d[a.ss.ff-1][ a.ss.ss-1]=a.ff;
        d[a.ss.ss-1][ a.ss.ff-1]=a.ff;
    }

    for (int k1 = 0; k1 < n; ++k1)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if (d[i][k1] < LLINF && d[k1][j] < LLINF)
                    d[i][j] = min(d[i][j], d[i][k1] + d[k1][j]);
            }
        }
    }
    vector<ll> ds;
    forn(i,2*min(k,m))
    {
        for(int z=i+1;z<2*min(k,m);z++)
        {
            ds.pb(d[i][z]);
       //     cout<<d[i][z]<<" ";
        }
        //cout<<endl;
    }
    sort(all(ds));
    cout<<ds[k-1]<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;

typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;

const int MAX = 1000010;
const int MOD = 1000000007;
const int INF = 1e5;
const ll LLINF = 1e18;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
//
bool comp(pair<int,pii> a, pair<int,pii> b)
{
    return a.ff<b.ff;
}
int main()
{
    int n,m,k;

    cin>>n>>m>>k;
    vector<vector<ll>> d;
    d.assign(n,vector<ll> (n));
    forn(i,n)
    {
        for(int j=0;j<n;j++)
        {
         d[i][j]=LLINF;
        }
    }
    vector<pair<int,pii>> ed(m);
    forn(i,m)
    {
        cin>>ed[i].ss.ff>>ed[i].ss.ss>>ed[i].ff;
    }
    sort(all(ed),comp);
    forn(i,min(k,m))
    {
        auto a=ed[i];
        d[a.ss.ff-1][ a.ss.ss-1]=a.ff;
        d[a.ss.ss-1][ a.ss.ff-1]=a.ff;
    }
  /*  forn(i,n)
    {
        for(int j=0;j<n;j++)
        {
        //    ds[j++]=d[i][j];
            cout<<d[i][j]<<" ";
        }
        cout<<endl;
    }*/
    for (int k1 = 0; k1 < n; ++k1)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if (d[i][k1] < LLINF && d[k1][j] < LLINF)
                    d[i][j] = min(d[i][j], d[i][k1] + d[k1][j]);
            }
        }
    }
    vector<ll> ds;
    forn(i,n)
    {
        for(int z=i+1;z<n;z++)
        {
            ds.pb(d[i][z]);
       //     cout<<d[i][z]<<" ";
        }
        //cout<<endl;
    }
    sort(all(ds));
    cout<<ds[k-1]<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;

typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;

const int MAX = 1000010;
const int MOD = 1000000007;
const int INF = 1e5;
const ll LLINF = 1e16;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
//
bool comp(pair<int,pii> a, pair<int,pii> b)
{
    return a.ff<b.ff;
}
int main()
{
    //sws
    int n,m,k;
    cin>>n>>m>>k;
    vector<pair<ll,pii>> ed(m);
    forn(i,m)
    {
        cin>>ed[i].ss.ff>>ed[i].ss.ss>>ed[i].ff;
        ed[i].ss.ss--;
        ed[i].ss.ff--;
    }
    sort(all(ed),comp);
    vi v;
    forn(i,min(m,k))
    {
        v.pb(ed[i].ss.ff);
        v.pb(ed[i].ss.ss);
    }
    sort(all(v));
    v.resize(unique(all(v))-v.begin());
    int num=v.size();
    cout<<num<<endl;
    vector<vector<ll>> d;
    d.resize(num,vector<ll> (num));
    forn(i,num)
    {
        for(int j=0;j<num;j++)
        {
         d[i][j]=LLINF;
        }
    }
    forn(i,min(k,m))
    {
        auto a=ed[i];
    //    cout<<a.ff<<" "<<a.ss.ff<<" "<<a.ss.ss<<endl;
        int one=lower_bound(all(v),a.ss.ff)-v.begin();
        int two=lower_bound(all(v),a.ss.ss)-v.begin();
      //  cout<<one<<" "<<two<<endl;
        d[one][two]=a.ff;
        d[two][ one]=a.ff;
    }
    //cout<<"hi"<<endl;
    for (int k1 = 0; k1 < num; ++k1)
    {
        for (int i = 0; i < num; ++i)
        {
            for (int j = 0; j < num; ++j)
            {
                if (d[i][k1] < LLINF && d[k1][j] < LLINF)
                    d[i][j] = min(d[i][j], d[i][k1] + d[k1][j]);
            }
        }
    }
    //cout<<"bye"<<endl;
    vector<ll> ds;
    forn(i,num)
    {
        for(int z=i+1;z<num;z++)
        {
            ds.pb(d[i][z]);
       //     cout<<d[i][z]<<" ";
        }
        //cout<<endl;
    }
    sort(all(ds));
    cout<<ds[k-1]<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;

typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;

const int MAX = 1000010;
const int MOD = 1000000007;
const int INF = 1e5;
const ll LLINF = 1e16;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
//
bool comp(pair<int,pii> a, pair<int,pii> b)
{
    return a.ff<b.ff;
}
int main()
{
    //sws
    int n,m,k;
    cin>>n>>m>>k;
    vector<pair<ll,pii>> ed(m);
    forn(i,m)
    {
        cin>>ed[i].ss.ff>>ed[i].ss.ss>>ed[i].ff;
        ed[i].ss.ss--;
        ed[i].ss.ff--;
    }
    sort(all(ed),comp);
    vi v;
    forn(i,min(m,k))
    {
        v.pb(ed[i].ss.ff);
        v.pb(ed[i].ss.ss);
    }
    sort(all(v));
    v.resize(unique(all(v))-v.begin());
    int num=v.size();
   // cout<<num<<endl;
    vector<vector<ll>> d;
    d.resize(num,vector<ll> (num));
    forn(i,num)
    {
        for(int j=0;j<num;j++)
        {
         d[i][j]=LLINF;
        }
    }
    forn(i,min(k,m))
    {
        auto a=ed[i];
    //    cout<<a.ff<<" "<<a.ss.ff<<" "<<a.ss.ss<<endl;
        int one=lower_bound(all(v),a.ss.ff)-v.begin();
        int two=lower_bound(all(v),a.ss.ss)-v.begin();
      //  cout<<one<<" "<<two<<endl;
        d[one][two]=a.ff;
        d[two][ one]=a.ff;
    }
    //cout<<"hi"<<endl;
    for (int k1 = 0; k1 < num; ++k1)
    {
        for (int i = 0; i < num; ++i)
        {
            for (int j = 0; j < num; ++j)
            {
                if (d[i][k1] < LLINF && d[k1][j] < LLINF)
                    d[i][j] = min(d[i][j], d[i][k1] + d[k1][j]);
            }
        }
    }
    //cout<<"bye"<<endl;
    vector<ll> ds;
    forn(i,num)
    {
        for(int z=i+1;z<num;z++)
        {
            ds.pb(d[i][z]);
       //     cout<<d[i][z]<<" ";
        }
        //cout<<endl;
    }
    sort(all(ds));
    cout<<ds[k-1]<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;

typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;

const int MAX = 1000010;
const int MOD = 1000000007;
const int INF = 1e5;
const ll LLINF = 1e12;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
//
bool comp(pair<int,pii> a, pair<int,pii> b)
{
    return a.ff<b.ff;
}
int main()
{
    int n,m,k;

    cin>>n>>m>>k;
    ll d[n][n];
    forn(i,n)
    {
        for(int j=0;j<n;j++)
        {
         d[i][j]=LLINF;
        }
    }
    vector<pair<int,pii>> ed(m);
    forn(i,m)
    {
        cin>>ed[i].ss.ff>>ed[i].ss.ss>>ed[i].ff;
    }
    sort(all(ed),comp);
    forn(i,min(k,m))
    {
        auto a=ed[i];
        d[a.ss.ff-1][ a.ss.ss-1]=a.ff;
        d[a.ss.ss-1][ a.ss.ff-1]=a.ff;
    }
  /*  forn(i,n)
    {
        for(int j=0;j<n;j++)
        {
        //    ds[j++]=d[i][j];
            cout<<d[i][j]<<" ";
        }
        cout<<endl;
    }*/
    for (int k1 = 0; k1 < n; ++k1)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if (d[i][k1] < LLINF && d[k1][j] < LLINF)
                    d[i][j] = min(d[i][j], d[i][k1] + d[k1][j]);
            }
        }
    }
    vector<ll> ds;
    forn(i,n)
    {
        for(int z=i+1;z<n;z++)
        {
            ds.pb(d[i][z]);
       //     cout<<d[i][z]<<" ";
        }
        //cout<<endl;
    }
    sort(all(ds));
    cout<<ds[k-1]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fe(i,a,b) for(int i=(a);i<=(b);i++)
#define fne(i,a,b) for(int i=(a);i<(b);i++)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%lld",&x)                   //注意ll读入
#define mst(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls l,m,lc
#define rs m+1,r,rc
#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl;
#define dbg3(x,y,z) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl;
const int INF =0x3f3f3f3f;
const int mod = 1e9+7;
const double eps=1e-8;
const int N = 2e5+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

struct Anode{
	int u,v,cost;
	bool operator < (const Anode b){
		return cost<b.cost;
	}
};

struct node{
	int v,cost;
};
int main(){
//	freopen("Fin1.txt","r",stdin);
//	freopen("Fin2.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	int n,m,k;
	read3(n,m,k);
//	dbg3(n,m,k);
	int u,v,cost;
	vector<Anode>tmp;
	fe(i,1,m){
		read3(u,v,cost);
		tmp.pb(Anode{u,v,cost});
	}
    sort(all(tmp));
//    for(auto it:tmp)cout<<it.cost<<" ";puts("");
    vector<int>allnode;
	fne(i,0,k){
    	u = tmp[i].u,v=tmp[i].v,cost = tmp[i].cost;
    	allnode.pb(u);
    	allnode.pb(v);
//    	dbg(cost);C
    }
    sort(all(allnode));
    auto ed = unique(all(allnode));
    int totn = ed-allnode.begin();
//    fne(i,0,totn)printf("%d%c",allnode[i],i==totn-1?'\n':' ');
    vector<vector<int> > d(totn+5,vector<int>(totn+5));
    fne(i,0,totn){
		fne(j,0,totn){
			d[i][j] = INF;
		}
    }
	int sz = tmp.size();
    fne(i,0,min(k,sz) ){
    	u = tmp[i].u,v=tmp[i].v,cost=tmp[i].cost;
		u = lower_bound(allnode.begin(),ed,u)-allnode.begin();
		v = lower_bound(allnode.begin(),ed,v)-allnode.begin();
//		dbg3(u,v,cost);
		d[u][v] = d[v][u] = cost;
    }
	fne(i,0,totn){
		fne(j,0,totn){
			fne(k,0,totn){
				d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
			}
		}
	}
	vector<int>res;
	fne(i,0,totn){
		fne(j,0,i){
            if(d[i][j]!=INF)res.pb(d[i][j]);
		}
	}
	sort(all(res));
//	for(it:res)cout<<it<<" ";puts("");
	printf("%d\n",res[k-1]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fe(i,a,b) for(int i=(a);i<=(b);i++)
#define fne(i,a,b) for(int i=(a);i<(b);i++)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%lld",&x)                   //注意ll读入
#define mst(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls l,m,lc
#define rs m+1,r,rc
#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl;
#define dbg3(x,y,z) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl;
const int INF =0x3f3f3f3f;
const int mod = 1e9+7;
const double eps=1e-8;
const int N = 2e5+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

struct Anode{
	int u,v,cost;
	bool operator < (const Anode b){
		return cost<b.cost;
	}
};

struct node{
	int v,cost;
};
int main(){
//	freopen("Fin1.txt","r",stdin);
//	freopen("Fin2.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	int n,m,k;
	read3(n,m,k);
//	dbg3(n,m,k);
	int u,v,cost;
	vector<Anode>tmp;
	fe(i,1,m){
		read3(u,v,cost);
		tmp.pb(Anode{u,v,cost});
	}
    sort(all(tmp));
    vector<int>allnode;
	fne(i,0,k){
    	u = tmp[i].u,v=tmp[i].v,cost = tmp[i].cost;
    	allnode.pb(u);
    	allnode.pb(v);
//    	dbg(cost);C
    }
    sort(all(allnode));
    auto ed = unique(all(allnode));
    int totn = ed-allnode.begin();
//    fne(i,0,totn)printf("%d%c",allnode[i],i==totn-1?'\n':' ');
    vector<vector<int> > d(totn+5,vector<int>(totn+5));
    fne(i,0,totn){
		fne(j,0,totn){
			d[i][j] = INF;
		}
    }
    fne(i,0,k){
    	u = tmp[i].u,v=tmp[i].v,cost=tmp[i].cost;
		u = lower_bound(allnode.begin(),ed,u)-allnode.begin();
		v = lower_bound(allnode.begin(),ed,v)-allnode.begin();
		d[u][v] = d[v][u] = cost;
    }
	fne(i,0,totn){
		fne(j,0,totn){
			fne(k,0,totn){
				d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
			}
		}
	}
	vector<int>res;
	fne(i,0,totn){
		fne(j,0,i){
            if(d[i][j]!=INF)res.pb(d[i][j]);
		}
	}
	sort(all(res));
//	for(it:res)cout<<it<<" ";puts("");
	printf("%d\n",res[k-1]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fe(i,a,b) for(int i=(a);i<=(b);i++)
#define fne(i,a,b) for(int i=(a);i<(b);i++)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%lld",&x)                   //注意ll读入
#define mst(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls l,m,lc
#define rs m+1,r,rc
#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl;
#define dbg3(x,y,z) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl;
const ll INF =4e18;
const int mod = 1e9+7;
const double eps=1e-8;
const int N = 2e5+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

struct Anode{
	int u,v,cost;
	bool operator < (const Anode b){
		return cost<b.cost;
	}
};

struct node{
	int v,cost;
};
int main(){
//	freopen("Fin1.txt","r",stdin);
//	freopen("Fin2.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	int n,m,k;
	read3(n,m,k);
//	dbg3(n,m,k);
	int u,v,cost;
	vector<Anode>tmp;
	fe(i,1,m){
		read3(u,v,cost);
		tmp.pb(Anode{u,v,cost});
	}
    sort(all(tmp));
//    for(auto it:tmp)cout<<it.cost<<" ";puts("");
    vector<int>allnode;
	fne(i,0,min(k,m)){
    	u = tmp[i].u,v=tmp[i].v,cost = tmp[i].cost;
    	allnode.pb(u);
    	allnode.pb(v);
//    	dbg(cost);C
    }
    sort(all(allnode));
    auto ed = unique(all(allnode));
    int totn = ed-allnode.begin();
//    fne(i,0,totn)printf("%d%c",allnode[i],i==totn-1?'\n':' ');
    vector<vector<ll> > d(totn+5,vector<ll>(totn+5));
    fne(i,0,totn){
		fne(j,0,totn){
			d[i][j] = INF;
		}
    }
    fne(i,0,min(k,m) ){
    	u = tmp[i].u,v=tmp[i].v,cost=tmp[i].cost;
		u = lower_bound(allnode.begin(),ed,u)-allnode.begin();
		v = lower_bound(allnode.begin(),ed,v)-allnode.begin();
//		dbg3(u,v,cost);
		d[u][v] = d[v][u] = 1ll*cost;
    }
	fne(i,0,totn){
		fne(j,0,totn){
			fne(k,0,totn){
				d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
			}
		}
	}
	vector<ll>res;
	fne(i,0,totn){
		fne(j,0,i){
//			dbg(d[i][j]);
            if(d[i][j]!=INF)res.pb(d[i][j]);
		}
	}

	sort(all(res));
//	for(it:res)cout<<it<<" ";puts("");
	printf("%lld\n",res[k-1]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fe(i,a,b) for(int i=(a);i<=(b);i++)
#define fne(i,a,b) for(int i=(a);i<(b);i++)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%lld",&x)                   //注意ll读入
#define mst(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls l,m,lc
#define rs m+1,r,rc
#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl;
#define dbg3(x,y,z) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl;
const int INF =0x3f3f3f3f;
const int mod = 1e9+7;
const double eps=1e-8;
const int N = 2e5+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

struct Anode{
	int u,v,cost;
	bool operator < (const Anode b){
		return cost<b.cost;
	}
};

struct node{
	int v,cost;
};
int main(){
//	freopen("Fin1.txt","r",stdin);
//	freopen("Fin2.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	int n,m,k;
	read3(n,m,k);
//	dbg3(n,m,k);
	int u,v,cost;
	vector<Anode>tmp;
	fe(i,1,m){
		read3(u,v,cost);
		tmp.pb(Anode{u,v,cost});
	}
    sort(all(tmp));
//    for(auto it:tmp)cout<<it.cost<<" ";puts("");
    vector<int>allnode;
	int sz = tmp.size();
	fne(i,0,min(k,sz)){
    	u = tmp[i].u,v=tmp[i].v,cost = tmp[i].cost;
    	allnode.pb(u);
    	allnode.pb(v);
//    	dbg(cost);C
    }
    sort(all(allnode));
    auto ed = unique(all(allnode));
    int totn = ed-allnode.begin();
//    fne(i,0,totn)printf("%d%c",allnode[i],i==totn-1?'\n':' ');
    vector<vector<int> > d(totn+5,vector<int>(totn+5));
    fne(i,0,totn){
		fne(j,0,totn){
			d[i][j] = INF;
		}
    }
    fne(i,0,min(k,sz) ){
    	u = tmp[i].u,v=tmp[i].v,cost=tmp[i].cost;
		u = lower_bound(allnode.begin(),ed,u)-allnode.begin();
		v = lower_bound(allnode.begin(),ed,v)-allnode.begin();
//		dbg3(u,v,cost);
		d[u][v] = d[v][u] = cost;
    }
	fne(i,0,totn){
		fne(j,0,totn){
			fne(k,0,totn){
				d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
			}
		}
	}
	vector<int>res;
	fne(i,0,totn){
		fne(j,0,i){
            if(d[i][j]!=INF)res.pb(d[i][j]);
		}
	}
	sort(all(res));
//	for(it:res)cout<<it<<" ";puts("");
	printf("%d\n",res[k-1]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fe(i,a,b) for(int i=(a);i<=(b);i++)
#define fne(i,a,b) for(int i=(a);i<(b);i++)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%lld",&x)                   //注意ll读入
#define mst(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls l,m,lc
#define rs m+1,r,rc
#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl;
#define dbg3(x,y,z) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl;
const int INF =0x3f3f3f3f;
const int mod = 1e9+7;
const double eps=1e-8;
const int N = 2e5+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

struct Anode{
	int u,v,cost;
	bool operator < (const Anode b){
		return cost<b.cost;
	}
};

struct node{
	int v,cost;
};
int main(){
//	freopen("Fin1.txt","r",stdin);
	freopen("Fin2.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	int n,m,k;
	read3(n,m,k);
//	dbg3(n,m,k);
	int u,v,cost;
	vector<Anode>tmp;
	fe(i,1,m){
		read3(u,v,cost);
		tmp.pb(Anode{u,v,cost});
	}
    sort(all(tmp));
    vector<int>allnode;
	fne(i,0,k){
    	u = tmp[i].u,v=tmp[i].v,cost = tmp[i].cost;
    	allnode.pb(u);
    	allnode.pb(v);
//    	dbg(cost);C
    }
    sort(all(allnode));
    auto ed = unique(all(allnode));
    int totn = ed-allnode.begin();
//    fne(i,0,totn)printf("%d%c",allnode[i],i==totn-1?'\n':' ');
    vector<vector<ll> > d(totn+5,vector<ll>(totn+5));
    fne(i,0,totn){
		fne(j,0,totn){
			d[i][j] = INF;
		}
    }
    fne(i,0,k){
    	u = tmp[i].u,v=tmp[i].v,cost=tmp[i].cost;
		u = lower_bound(allnode.begin(),ed,u)-allnode.begin();
		v = lower_bound(allnode.begin(),ed,v)-allnode.begin();
		d[u][v] = d[v][u] = cost;
    }
	fne(i,0,totn){
		fne(j,0,totn){
			fne(k,0,totn){
				d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
			}
		}
	}
	vector<int>res;
	fne(i,0,totn){
		fne(j,0,i){
            if(d[i][j]!=INF)res.pb(d[i][j]);
		}
	}
	sort(all(res));
//	for(it:res)cout<<it<<" ";puts("");
	printf("%d\n",res[k-1]);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long NMax = 200005;
const long long INF = 1000000000000000003;
const long long KMax = 405;

struct Edge{
    long long x,y,c;
};

long long n,m,k,x,y,c,nr,ans_nr;
Edge M[NMax];
long long ans[NMax];
long long dist[KMax][KMax];
map<long long,long long> vert;
map<long long,long long> edge;
map<long long,long long> cod;
map<long long,long long> decod;

bool cmp(Edge x, Edge y){
    return (x.c < y.c);
}
int main(){
    cin >> n >> m >> k;
    for(long long i = 1; i <= m; ++i){
        cin >> x >> y >> c;
        M[i].x = x;
        M[i].y = y;
        M[i].c = c;
    }
    sort(M + 1, M + 1 + m, cmp);
    ans_nr = 1;
    for(long long i = 1; i <= min(k,m); ++i){
        vert[M[i].x] = 1;
        vert[M[i].y] = 1;
        edge[i] = 1;
    }
    long long coddd = 1;
    for(auto i : vert){
            cod[i.first] = coddd;
            decod[coddd] = i.first;
            coddd++;
    }
    int N = vert.size();
    for(long long i = 1; i <= N; ++i){
        for(long long j = 1; j <= N; ++j){
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }
    for(auto i : edge){
        dist[cod[M[i.first].x]][cod[M[i.first].y]] = M[i.first].c;
        dist[cod[M[i.first].y]][cod[M[i.first].x]] = M[i.first].c;
    }
    for(long long i = 1; i <= N; ++i){
        for(long long j = 1; j <= N; ++j){
            for(long long l = 1; l <= N; ++l){
                if(j != l && dist[j][l] > dist[j][i] + dist[i][l]){
                    dist[j][l] = dist[j][i] + dist[i][l];
                }
            }
        }
    }
    //cout << '\n';
    vector<long long> v;
    for(long long i = 1; i <= N; ++i){
        for(long long j = i + 1; j <= N; ++j){
            v.push_back(dist[i][j]);
        }
        //cout << '\n';
    }
    sort(v.begin(), v.end());
    cout << v[k - 1] << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long NMax = 200005;
const long long INF = 1000000000000000003;
const long long KMax = 405;

struct Edge{
    long long x,y,c;
};

long long n,m,k,x,y,c,nr,ans_nr;
Edge M[NMax];
long long ans[NMax];
long long dist[KMax][KMax];
map<long long,long long> vert;
map<long long,long long> edge;
map<long long,long long> cod;
map<long long,long long> decod;

bool cmp(Edge x, Edge y){
    return (x.c < y.c);
}
int main(){
    cin >> n >> m >> k;
    for(long long i = 1; i <= m; ++i){
        cin >> x >> y >> c;
        M[i].x = x;
        M[i].y = y;
        M[i].c = c;
    }
    sort(M + 1, M + 1 + m, cmp);
    ans_nr = 1;
    for(long long i = 1; i <= m; ++i){
        if(edge.size() > 2 * min(k, m) )
            break;
        vert[M[i].x] = 1;
        vert[M[i].y] = 1;
        edge[i] = 1;
    }
    long long coddd = 1;
    for(auto i : vert){
        cod[i.first] = coddd;
        decod[coddd] = i.first;
        coddd++;
    }
    int N = vert.size();
    for(long long i = 1; i <= N; ++i){
        for(long long j = 1; j <= N; ++j){
            dist[i][j] = INF;
        }
        //dist[i][i] = 0;
    }
    for(auto i : edge){
        dist[cod[M[i.first].x]][cod[M[i.first].y]] = M[i.first].c;
        dist[cod[M[i.first].y]][cod[M[i.first].x]] = M[i.first].c;
    }
    for(long long i = 1; i <= N; ++i){
        for(long long j = 1; j <= N; ++j){
            for(long long l = 1; l <= N; ++l){
                if(j != l && dist[j][l] > dist[j][i] + dist[i][l]){
                    dist[j][l] = dist[j][i] + dist[i][l];
                }
            }
        }
    }
    //cout << '\n';
    vector<long long> v;
    for(long long i = 1; i <= N; ++i){
        for(long long j = i; j <= N; ++j){
            //cout << dist[i][j] << ' ';
            if(i != j)
                v.push_back(dist[i][j]);
        }
        //cout << '\n';
    }
    sort(v.begin(), v.end());
    cout << v[k - 1] << '\n';
    return 0;
}


fases = int(raw_input())
fasesindices = []
for i in range(fases):
    fasesindices.append(i+1)
fasepassou = []

indicesX = raw_input().split()
indicesY = raw_input().split()

fasesY = [] #esta em int
fasesX = [] #esta em int

for i in range(int(indicesY[0])):
    fasesY.append(int(indicesY[i+1]))
for i in range(int(indicesX[0])):
    fasesX.append(int(indicesX[i+1]))

for i in range(len(fasesX)):
    for x in range(len(fasesindices)-1,-1,-1):
        if fasesX[i] == fasesindices[x]:
            fasesindices.pop(x)

for i in range(len(fasesY)):
    for x in range(len(fasesindices)-1,-1,-1):
        if fasesY[i] == fasesindices[x]:
            fasesindices.pop(x)

if fasesindices == fasepassou:
    print 'I become the guy.'
else:
    print 'Oh, my keyboard!'

#print fasesindices
#print fasesX
#print fasesY


fases = int(raw_input())
fasesindices = []
for i in range(fases):
    fasesindices.append(i+1)
fasepassou = []

indicesX = raw_input().split()
indicesY = raw_input().split()

fasesY = [] #esta em int
fasesX = [] #esta em int

for i in range(int(indicesX[0])):
    fasesY.append(int(indicesY[i]))
for i in range(int(indicesX[0])):
    fasesX.append(int(indicesX[i+1]))

for i in range(len(fasesX)):
    for x in range(len(fasesindices)-1,-1,-1):
        if fasesX[i] == fasesindices[x]:
            fasesindices.pop(x)

for i in range(len(fasesY)):
    for x in range(len(fasesindices)-1,-1,-1):
        if fasesY[i] == fasesindices[x]:
            fasesindices.pop(x)

if fasesindices == fasepassou:
    print 'I become the guy.'
else:
    print 'Oh, my keyboard!'

#print fasesindices
#print fasesX
#print fasesY


def main():
    n = int(raw_input())

    L1 = [ int(i) for i in raw_input().split(" ") ]
    L2 = [ int(i) for i in raw_input().split(" ") ]

    H = {}
    for i in range(1,len(L1)):
        H[L1[i]] = True
    for i in range(1,len(L2)):
        H[L2[i]] = True

    if len(H) == n:
        print "I become the guy."
    else:
        print "Oh, my keyboard!"

main()


n = int(raw_input())
l = [int(x) for x in raw_input().split()[1:]]
m = [int(x) for x in raw_input().split()[1:]]
for i in m:
  if i in l: continue
  else:l.append(i)

if len(l)==n:
  print "I become the guy."
else:
  print "Oh, my keyboard!"


n = int(raw_input())
l = [int(x) for x in raw_input().split()[1:]]
m = [int(x) for x in raw_input().split()[1:]]
for i in m:
  if i in l: continue
  else:l.append(i)

if len(l)==n:
  print "I become the guy"
else:
  print "Oh, my keyboard!"


n = int(raw_input())
l = [int(x) for x in raw_input().split()[1:]]
m = [int(x) for x in raw_input().split()[1:]]
for i in m:
  if i in l: continue
  else:l.append(i)

if len(i)==n:
  print "I become the guy"
else:
  print "Oh, my keyboard!"


from __future__ import division, print_function

import sys
from atexit import register

if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream

sys.stdin = stream(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')

sys.stdout = stream()
register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def read_int():
    return int(input())

def read_ints():
    return list(map(int, input().split(' ')))

def solve():
    N = read_int()
    levels = [False]*N
    for _ in range(2):
        p, *A = read_ints()
        for a in A:
            levels[a-1] = True
    if sum(levels) == N:
        return 'I become the guy.'
    return 'Oh, my keyboard!'

if __name__ == '__main__':
    print(solve())


from __future__ import division, print_function

import sys
from atexit import register

if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream

sys.stdin = stream(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')

sys.stdout = stream()
register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def read_int():
    return int(input())

def read_ints():
    return list(map(int, input().split(' ')))

def solve():
    N = read_int()
    levels = [False]*N
    for _ in range(2):
        A = read_ints()
        for a in A[1:]:
            levels[a-1] = True
    if sum(levels) == N:
        return 'I become the guy.'
    return 'Oh, my keyboard!'

if __name__ == '__main__':
    print(solve())


if __name__ == '__main__':
    n = int(raw_input())

    ps = [int(num) for num in raw_input().split()]
    qs = [int(num) for num in raw_input().split()]

    p, ps = ps[0], ps[1:]
    q, qs = qs[0], qs[1:]

    print 'I become the guy.' if len(set(ps+qs)) == n else 'Oh, my keyboard!'


n = int(raw_input())
l = raw_input().split()
l.extend(raw_input().split())
c = set(l)

print c
if len(c) >= n:
	print "I become the guy."

else:
	print "Oh, my keyboard!"


n = int(raw_input())
l = raw_input().split()
l.pop(0)
m = raw_input().split()
m.pop(0)
l.extend(m)
c = set(l)

if '0' in c:
	c.remove('0')

if len(c) >= n:
	print "I become the guy."

else:
	print "Oh, my keyboard!"


n = int(raw_input())
l = raw_input().split()
l.extend(raw_input().split())
c = set(l)

if len(c) == n:
	print "I become the guy."

else:
	print "Oh, my keyboard!"


n = int(raw_input())
l = raw_input().split()
l.extend(raw_input().split())
c = set(l)

if len(c) >= n:
	print "I become the guy."

else:
	print "Oh, my keyboard!"


n = int(raw_input())
l = raw_input().split()
l.extend(raw_input().split())
c = set(l)

c.remove('0')

if len(c) >= n:
	print "I become the guy."

else:
	print "Oh, my keyboard!"


n = int(raw_input())
l = raw_input().split()
l.extend(raw_input().split())
c = set(l)

if 0 in c:
	c.remove(0)

if len(c) >= n:
	print "I become the guy."

else:
	print "Oh, my keyboard!"


n = int(raw_input())
l = raw_input().split()
l.extend(raw_input().split())
c = set(l)

if '0' in c:
	c.remove('0')

if len(c) >= n:
	print "I become the guy."

else:
	print "Oh, my keyboard!"


#Kakashi_O_Melhor
n = int(raw_input())

p = map(int,raw_input().split())
q = map(int,raw_input().split())

l = []
l2 = range(n+1)

for i in xrange(len(p)):
    if p[i] not in l:
        l.append(p[i])

for i in xrange(len(q)):
    if q[i] not in l:
        l.append(q[i])

l.sort()
if l[0] != 0:
    l2.pop(0)

if l == l2:
    print "I become the guy."
else:
    print "Oh, my keyboard!"


#Kakashi_O_Melhor
n = int(raw_input())

p = map(int,raw_input().split())
q = map(int,raw_input().split())

l = []
l2 = range(1,n+1)

for i in xrange(1,len(p)):
    if p[i] not in l and p[i] != 0:
        l.append(p[i])

for i in xrange(1,len(q)):
    if q[i] not in l and q[i] != 0:
        l.append(q[i])

l.sort()
if l == l2:
    print "I become the guy."
else:
    print "Oh, my keyboard!"


#Kakashi_O_Melhor
n = int(raw_input())

p = map(int,raw_input().split())
q = map(int,raw_input().split())

l = []
l2 = range(n+1)
l2.pop(0)

for i in xrange(len(p)):
    if p[i] not in l:
        l.append(p[i])

for i in xrange(len(q)):
    if q[i] not in l:
        l.append(q[i])

l.sort()
if l == l2:
    print "I become the guy."
else:
    print "Oh, my keyboard!"


R=lambda:map(int,raw_input().split())[1:]
print ["Oh, my keyboard!","I become the guy."][input()==len(set(R()).union(set(R())))]


# coding=utf-8
__author__ = 'andre'

"""
/*******************************************************************************
 * Aluno:  André Meneghelli Vale,      Núm. USP: 4898948
 * Curso: Bacharelado em Ciências da Computação
 * Aula 2 - Desafio A
 * MAC0327 -- 08/07/2015 -- IME/USP, -- Prof. Cristina Gomes Fernandes
 ******************************************************************************/
"""

def main():
    levels = int(raw_input())
    xplayer = map(int, raw_input().split())
    yplayer = map(int, raw_input().split())
    xlevels = xplayer[1:]
    ylevels = yplayer[1:]
    wins = set(xlevels+ylevels)

    if len(wins) == levels and sum(wins) == (levels+1)*levels/2:
        print "I become the guy."
    else:
        print "Oh, my keyboard!"

if __name__ == "__main__":
    main()


n=input()
a=set(map(int,raw_input().split())+map(int,raw_input().split()))
print "I become the guy." if len(a)==n else "Oh, my keyboard!"


n=input()
a=set(map(int,raw_input().split())[1:]+map(int,raw_input().split())[1:])
print "I become the guy." if len(a)==n else "Oh, my keyboard!"


from sys import stdin
import copy
lines = stdin.readlines()

n = int(lines[0])
p = int(lines[1].split()[0])
a1 = map(int,lines[1].split()[1:])
q = int(lines[2].split()[0])
a2 = map(int,lines[2].split()[1:])
liste = [i for i in range(1,n+1)]
for i in range(p):
    liste.remove(a1[i])
for i in range(q):
    if a2[i] in liste:
        liste.remove(a2[i])

if liste == []:
    print "I become the guy."
else:
    print "Oh, my keyboard!"


linha = int(raw_input())
linha2 = map(int, raw_input().split())
linha3 = map(int, raw_input().split())
gaspar = range(1,linha+1)
for i in xrange(1,len(linha2)):
	if linha2[i] in gaspar:
		gaspar.remove(linha2[i])
for g in xrange(1,len(linha3)):
	if linha3[g] in gaspar:
		gaspar.remove(linha3[g])
if len(gaspar)==0:
	print "I become the guy."
else:
	print "Oh, my keyboard!"


linha = int(raw_input())
linha2 = map(int, raw_input().split())
linha3 = map(int, raw_input().split())
gaspar = range(1,linha+1)
for i in xrange(len(linha2)):
	if linha2[i] in gaspar:
		gaspar.remove(linha2[i])
for g in xrange(len(linha3)):
	if linha3[g] in gaspar:
		gaspar.remove(linha3[g])
if len(gaspar)==0:
	print "I become the guy."
else:
	print "Oh, my keyboard!"


n=input()
n=[i for i in range(1,n+1)]
l=map(int,raw_input().split())
l.remove(l[0])
m=map(int,raw_input().split())
m.remove(m[0])
l+=m
print l
for i in n:
    if i not in l:
        print "Oh, my keyboard!"
        break
else:
    print"I become the guy."


n=input()
n=[i for i in range(1,n+1)]
l=map(int,raw_input().split())
l.remove(n[0])
m=map(int,raw_input().split())
m.remove(m[0])
l+=m
for i in n:
    if i not in l:
        print "Oh, my keyboard!"
        break
else:
    print"I become the guy."


n=input()
n=[i for i in range(1,n+1)]
l=map(int,raw_input().split())
l.remove(l[0])
m=map(int,raw_input().split())
m.remove(m[0])
l+=m
for i in n:
    if i not in l:
        print "Oh, my keyboard!"
        break
else:
    print"I become the guy."


n = input()
p = map(int,raw_input().split())
q = map(int,raw_input().split())
print "I become the guy." if len(set(p[1:] + q[1:])) == n else "Oh, my keyboard!"


n = input()
p = map(int,raw_input().split())
q = map(int,raw_input().split())
print "I become the guy." if len(set(p + q)) == n else "Oh, my keyboard!"


n = input()
l = list(map(int,raw_input().split()))
li = list(map(int,raw_input().split()))
s = set(l[1:]+li[1:])
if 0 in s:
	s.remove(0)
if len(s) >= n:
	print "I become the guy."
else:
	print "Oh, my keyboard!"


n=int(raw_input())
p=map(int,raw_input().split())
q=map(int,raw_input().split())
dict={}
for i in range(1,n+1):
	dict[i]=0
for i in range(1,p[0]+1):
	dict[p[i]]=dict[p[i]]+1
for j in range(1,q[0]+1):
	dict[q[j]]=dict[q[j]]+1
check= 0
for i in range(1,n+1):
	if(dict[i]==0):
		check=1
		print "Oh, my keyboard!"
if (check==0):
	print "I become the guy."


n=int(raw_input())
p=map(int,raw_input().split())
q=map(int,raw_input().split())
dict={}
for i in range(1,n+1):
	dict[i]=0
for i in range(1,p[0]+1):
	dict[p[i]]=dict[p[i]]+1
for j in range(1,q[0]+1):
	dict[q[j]]=dict[q[j]]+1
check= 0
for i in range(1,n+1):
	if(dict[i]==0):
		check=1
		print "Oh, my keyboard!"
		break
if (check==0):
	print "I become the guy."


n = int(raw_input())
x = list(map(int,raw_input().split()))
p = x[1:]
y= list(map(int,raw_input().split()))
q = y[1:]
i = 0
d = {}
while i < len(p):
    if p[i] not in d:
        d.update({p[i]:1})
    i += 1
i = 0
while i < len(q):
    if q[i] not in d:
        d.update({q[i]:1})
    i += 1
if len(d) == n:
    print "I become the guy."
else:
    print "Oh, my keyboard!"


a=int(input())
lis=set(a.split()[1:]+a.split()[1:])
if (len(lis))>a:
	print("I become the guy.")
else:
	print("Oh, my keyboard!")


n=int(input())
lis=input().split()[1:]+input().split()[1:]
if (len(set(lis)))>n:
	print("I become the guy.")
else:
	print("Oh, my keyboard!")


n=int(input())
lis=set(input().split()[1:]+input().split()[1:])
if (len(lis))>=n:
	print("I become the guy.")
else:
	print("Oh, my keyboard!")


a=int(input())
lis=set(a.split()[1:]+a.split()[1:])
if (len(lis))>n:
	print("I become the guy.")
else:
	print("Oh, my keyboard!")


n=int(input())
lis=input()[1:]+input()[1:]
if (len(set(lis)))>n:
	print("I become the guy.")
else:
	print("Oh, my keyboard!")


n=int(input())
lis=set(input().split()[1:]+input().split()[1:])
if (len(lis))>n:
	print("I become the guy.")
else:
	print("Oh, my keyboard!")


n=int(input())
lis=input()+input()
if (len(set(lis))-1)==n:
	print("I become the guy.")
else:
	print("Oh, my keyboard!")


from sys import stdin, stdout, stderr
import sys
inints=lambda: [int(x) for x in stdin.readline().split()]
fastwrite=lambda s: stdout.write( str(s) + "\n" )
fasterr=lambda s: stderr.write( str(s) + "\n" )
irange=lambda x,y: range(x, y+1)
####
n,=inints()
r=[False]*(n+1)
r[0]=True

a=inints()
b=inints()
c=a+b

for i in c:
    r[i]=True

q=True
for i in r:
    q=q and i

fastwrite( "I become the guy" if q else "Oh, my keyboard!" )


from sys import stdin, stdout, stderr
import sys
inints=lambda: [int(x) for x in stdin.readline().split()]
fastwrite=lambda s: stdout.write( str(s) + "\n" )
fasterr=lambda s: stderr.write( str(s) + "\n" )
irange=lambda x,y: range(x, y+1)
####
n,=inints()
r=[False]*(n+1)
r[0]=True

x,a=inints()
x,b=inints()
c=a+b

for i in c:
    r[i]=True

q=True
for i in r:
    q=q and i

fastwrite( "I become the guy." if q else "Oh, my keyboard!" )


from sys import stdin, stdout, stderr
import sys
inints=lambda: [int(x) for x in stdin.readline().split()]
fastwrite=lambda s: stdout.write( str(s) + "\n" )
fasterr=lambda s: stderr.write( str(s) + "\n" )
irange=lambda x,y: range(x, y+1)
####
n,=inints()
r=[False]*(n+1)
r[0]=True

a=inints()
b=inints()
c=a+b

for i in c:
    r[i]=True

q=True
for i in r:
    q=q and i

fastwrite( "I become the guy." if q else "Oh, my keyboard!" )


from sys import stdin, stdout, stderr
import sys
inints=lambda: [int(x) for x in stdin.readline().split()]
fastwrite=lambda s: stdout.write( str(s) + "\n" )
fasterr=lambda s: stderr.write( str(s) + "\n" )
irange=lambda x,y: range(x, y+1)
####
n,=inints()
r=[False]*(n+1)
r[0]=True

a=inints()[1:]
b=inints()[1:]
c=a+b

for i in c:
    r[i]=True

q=True
for i in r:
    q=q and i

fastwrite( "I become the guy." if q else "Oh, my keyboard!" )


from sys import stdin, stdout, stderr
import sys
inints=lambda: [int(x) for x in stdin.readline().split()]
fastwrite=lambda s: stdout.write( str(s) + "\n" )
fasterr=lambda s: stderr.write( str(s) + "\n" )
irange=lambda x,y: range(x, y+1)
####
n,=inints()
r=[False]*(n+1)
r[0]=True

a=inints()[0:]
b=inints()[0:]
c=a+b

for i in c:
    r[i]=True

q=True
for i in r:
    q=q and i

fastwrite( "I become the guy." if q else "Oh, my keyboard!" )


n=int(input())
p=input().split()
q=input().split()
m = p[1:]
j = q[1:]
if len(set(m+j))==n:
      print("I become the guy.")
else:
      print("Oh, my keyboard!")


n= int(input())

a= list(map(int, input().split()))
b= list(map(int, input().split()))
c= a+b
c=set(c)
c.remove(0)
if n==len(c):
    print("I become the guy.")
else:
    print("Oh, my keyboard!")


n= int(input())

a= list(map(int, input().split()))
b= list(map(int, input().split()))
c= a+b
c=set(c)
if n<=len(c):
    print("I become the guy.")
else:
    print("Oh, my keyboard!")


n= int(input())

a= list(map(int, input().split()))
b= list(map(int, input().split()))
c= a+b
c=set(c)
if len(c)==n:
    print("I become the guy.")
else:
    print("Oh, my keyboard!")


n= int(input())

a= list(map(int, input().split()))
b= list(map(int, input().split()))
c= a+b
c=set(c)
if 0 in c:
    c.remove(0)
if n==len(c):
    print("I become the guy.")
else:
    print("Oh, my keyboard!")


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#ifndef ONLINE_JUDGE
bool ipfile = freopen("ip.txt","r",stdin);
bool opfile = freopen("op.txt","w",stdout);
#endif
using namespace std;
int n,m,x,y,t,q;

double ans,h,l;

int main()
{
    fast
    while(cin>>n>>m)
    {
        map<int,int>M;
        rep(i,n)
            cin>>q , M[q]++;

        x = 8*m - n;

    // pv(x);

        y=0;
        vi A;
        for(map<int,int>::iterator it = M.begin();it!= M.end();++it)
            A.pb(it->S);
        if( sz(A) <= x )
        {
            cout<<"0\n";
            continue;
        }
        sort(all(A));
        // rep(i,sz(A))
        //     cout<<A[i]<<" ";
        // nl;
        rep(i,sz(A)-x)
        {
            y += A[i];
        }
        cout<<y,nl;
    }

    return 0;
}


#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
bool ipfile = freopen("ip.txt","r",stdin);
bool opfile = freopen("op.txt","w",stdout);
#endif
using namespace std;
int n,m,x,y,t,q;
double ans,h,l;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    while(cin>>n>>m)
    {
        map<int,int>M;
        for ( int i=0 ; i < n ; i++ )
            cin>>q , M[q]++;
        x = 8*m - n;
        y=0, t=0;
        vector<int> first;
        int tot_sum = 0;
        for(map<int,int>::iterator it = M.begin();it!= M.end();++it)
            first.push_back(it->second) , tot_sum += it->second;
        int d = first.size();
        int k = (8*m) / n;
        if(k >= d or k >= 20)
        {
            cout<<"0\n";
            continue;
        }
        int K = 1 << k;
        for ( int i=0 ; i < K ; i++ )
            t += first[i];
        y = tot_sum - t;
        for ( int i=1 ; i < d-K+1 ; i++ )
        {
            t = t - first[i-1] + first[i+K-1];
            y = min(y, tot_sum - t);
        }
        cout<<y,cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
#define nl              cout<<"\n"
#define sz(x)           (int)((x).size())
#define len(x)          (x).length()
#define all(a)          (a).begin(),(a).end()
#define rep(i,n)        for( int i=0;i<(int)(n);i++)
#define brep(i,n)       for( int i=(n);i>=0;i-- )
#define repp(i,a,b)     for( int i = (a); i < (b); i++ )
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define vi      vector<int>
#define vll     vector<ll>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int> >
#define bits    __builtin_popcountll
#define mod     1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int tes; cin >> tes; while( tes-- > 0 )
#define pv(x) cout<< #x<< " = "<<(x)<<"\n";
#define foreach(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#ifndef ONLINE_JUDGE
bool ipfile = freopen("ip.txt","r",stdin);
bool opfile = freopen("op.txt","w",stdout);
#endif
using namespace std;
int n,m,x,y,t,q;
int a[400001];

double ans,h,l;

int main()
{
    fast
    while(cin>>n>>m)
    {
        map<int,int>M;
        rep(i,n)
            cin>>q , M[q]++;

        x = 8*m - n;
        y=0;
        vi A;
        for(map<int,int>::iterator it = M.begin();it!= M.end();++it)
            A.pb(it->S);
        if( sz(A) <= x )
        {
            cout<<"0\n";
            continue;
        }
        sort(all(A));
        rep(i,sz(A))
        {
            if(y >= x)
                break;
            y += A[i];
        }
        cout<<y,nl;
    }

    return 0;
}