#include<iostream>
using namespace std;

class Node{
public:
	long long m_value;
	long long m_index1;
	long long m_index2;
	Node(long long value, long long index1, long long index2){
		m_value = value;
		m_index1 = index1;
		m_index2 = index2;
	}
	~Node(){}
};

int main(void){
	long long NodeNum;
	cin >> NodeNum;
	long long EdgeNum;
	cin >> EdgeNum;
	long long KthNum;
	cin >> KthNum;
	long long CNum;

	if(KthNum <= EdgeNum){
		CNum = KthNum;
	}
	else
	{
		CNum = EdgeNum;
	}

	Node* Memo[EdgeNum+1];
	long long index1, index2, weight;
	for (int i = 1; i <= EdgeNum; ++i){
		cin>>index1>>index2>>weight;
		Memo[i] = new Node(weight,index1,index2);
	}

	//MinHeap:Build
	Node* temp01;
	for (int i = (EdgeNum >> 1); i >= 1; --i)
	{
		long long j = i;
		while(2*j <= EdgeNum){
			if(2*j+1 <= EdgeNum){
				if(Memo[2*j]->m_value < Memo[2*j+1]->m_value){
					temp01 = Memo[2*j];
					if(Memo[2*j]->m_value < Memo[j]->m_value){
						Memo[2*j] = Memo[j];
						Memo[j] = temp01;
						j = 2*j;
					}
					else
					{
						break;
					}
				}
				else{
					temp01 = Memo[2*j+1];
					if(Memo[2*j+1]->m_value < Memo[j]->m_value){
						Memo[2*j+1] = Memo[j];
						Memo[j] = temp01;
						j = 2*j + 1;
					}
					else{
						break;
					}
				}
			}
			else
			{
				temp01 = Memo[2*j];
				if(Memo[2*j]->m_value < Memo[j]->m_value){
					Memo[2*j] = Memo[j];
					Memo[j] = temp01;
					j = 2*j;
				}
				else
				{
					break;
				}
			}
		}
	}
	//MinHeap:Sort
	Node* Nodeptr;
	Node** Nodetail = &Memo[EdgeNum];
	Node* Memo1[CNum+1];
	for (int i = 1; i <= CNum; ++i){
		long long j = 1;
		Memo1[i] = Memo[1];
		Memo[1] = *Nodetail;
		*Nodetail = nullptr;
		Nodetail--;
		while(2*j <= EdgeNum - i){
			if(2*j+1 <= EdgeNum - i){
				if(Memo[2*j]->m_value < Memo[2*j+1]->m_value){
					temp01 = Memo[2*j];
					if(Memo[2*j]->m_value < Memo[j]->m_value){
						Memo[2*j] = Memo[j];
						Memo[j] = temp01;
						j = 2*j;
					}
					else{
						break;
					}
				}
				else{
					temp01 = Memo[2*j+1];
					if(Memo[2*j+1]->m_value < Memo[j]->m_value){
						Memo[2*j+1] = Memo[j];
						Memo[j] = temp01;
						j = 2*j + 1;
					}
					else{
						break;
					}
				}
			}
			else{
				temp01 = Memo[2*j];
				if(Memo[2*j]->m_value < Memo[j]->m_value){
					Memo[2*j] = Memo[j];
					Memo[j] = temp01;
					j = 2*j;
				}
				else{
					break;
				}
			}
		}
	}

	// for (int i = 1; i <= CNum; ++i)
	// {
	// 	cout<<Memo1[i] -> m_value<<" ";
	// }

	//Extract valid nodes
	int Index[NodeNum+1];
	int mcount = 0;
	for(int i = 0; i <= NodeNum; ++i)
		Index[i] = 0;

	for (int i = 1; i <= CNum; ++i)
	{
		if(Index[Memo1[i]->m_index1] == 0){
			Index[Memo1[i]->m_index1] = mcount;
			mcount++;
		}

		if(Index[Memo1[i] -> m_index2] == 0){
			Index[Memo1[i] -> m_index2] = mcount;
			mcount++;
		}
	}
	int Num = mcount-1;//The number of valid nodes.
	long long Path[Num+1][Num+1];
	for (int i = 1; i <= Num; ++i)
	{
		for (int j = 1; j <= Num; ++j)
		{
			Path[i][j] = 2000000001;
		}
	}
	for (int i = 1; i <= CNum; ++i)
	{
		Path[Index[Memo1[i]->m_index1]][Index[Memo1[i]->m_index2]] = Memo1[i] -> m_value;
		//cout<<"Index1: "<<Index[Memo1[i]->m_index1]<<" Index2: "<<Index[Memo1[i]->m_index2]<<" Value: "<<Memo1[i]->m_value<<endl;
		Path[Index[Memo1[i]->m_index2]][Index[Memo1[i]->m_index1]] = Memo1[i] -> m_value;
	}
	for (int i = 1; i <= Num; ++i)
	{
		Path[i][i] = 0;
	}

	// cout<<endl;
	// for (int i = 1; i <= Num; ++i)
	// {
	// 	for (int j = 1; j <= Num; ++j)
	// 	{
	// 		cout<<Path[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	// for(int i = 1; i <= Num; i++){
	// 	for (int j = 0; j <= Num; ++j)
	// 	{
	// 		cout<<Path[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	//Floyd's Algorithm
	for( int k = 1; k <= Num; ++k){
		for(int i = 1; i <= Num ; ++i){
			for(int j = 1; j <= Num ; ++j){
				if(Path[i][j] > Path[i][k] + Path[k][j])
					Path[i][j] = Path[i][k] + Path[k][j];
			}
		}
	}

	//Extracted
	long long PathNum = Num*(Num-1)/2;
	long long Mylist[PathNum+1];

	long long count = 1;
	for (long long i = 1; i <= Num; ++i)
	{
		for (long long j = i+1; j <= Num; ++j)
		{
			Mylist[count] = Path[i][j];
			count++;
		}
	}
	// MaxHeap-sort: Build
	long long temp;
	for (long long i = (PathNum >> 1); i >= 1; --i)
	{
		long long j = i;
		while(2*j <= PathNum){
			if(2*j+1 <= PathNum){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
		temp = 0;
	}

	// Max-Heap: Sort
	long long *TailPtr = &Mylist[PathNum];
	long long temp1;
	for (long long i = 1; i <= PathNum; ++i)
	{
		temp1 = Mylist[1];
		Mylist[1] = *TailPtr;
		*TailPtr = temp1;
		TailPtr--;
		long long j = 1;
		while(2*j <= PathNum - i){
			if(2*j+1 <= PathNum-i){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
	}

// cout<<endl;
// 	for (int i = 1; i <= PathNum; ++i)
// 	{
// 		cout<<Mylist[i]<<" ";
// 	}
//	cout<<endl;
	cout<<Mylist[KthNum];
	return 0;
}


#include<iostream>
using namespace std;

int main(void){
	unsigned long Num;
	cin >> Num;
	unsigned long Path[Num+1][Num+1];
	unsigned long EdgeNum;
	cin >> EdgeNum;
	unsigned long KthNum;
	cin >> KthNum;

	for(unsigned long i = 1; i <= Num; ++i){
		for(unsigned long j = 1; j <= Num; ++j){
			if(i == j)
				Path[i][j] = 0;
			else
				Path[i][j] = -1;
		}
	}

	for (unsigned long i = 0; i < EdgeNum; ++i)
	{
		unsigned long index1, index2;
		cin>>index1>>index2;
		cin >> Path[index1][index2];
		Path[index2][index1] = Path[index1][index2];
	}

	//Floyd's Algorithm
	for(unsigned long k = 1; k <= Num; ++k){
		for(unsigned long i = 1; i <= Num ; ++i){
			for(unsigned long j = 1; j <= Num ; ++j){
				if(Path[i][j] > Path[i][k] + Path[k][j])
					Path[i][j] = Path[i][k] + Path[k][j];
			}
		}
	}

	//Extracted
	unsigned long PathNum = Num*(Num-1)/2;
	unsigned long Mylist[PathNum+1];

	unsigned long count = 1;
	for (unsigned long i = 1; i <= Num; ++i)
	{
		for (unsigned long j = i+1; j <= Num; ++j)
		{
			Mylist[count] = Path[i][j];
			count++;
		}
	}
	// MaxHeap-sort: Build
	unsigned long temp;
	for (unsigned long i = (PathNum >> 1); i >= 1; --i)
	{
		unsigned long j = i;
		while(2*j <= PathNum){
			if(2*j+1 <= PathNum){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
		temp = 0;
	}

	// Max-Heap: Sort
	unsigned long *TailPtr = &Mylist[PathNum];
	unsigned long temp1;
	for (unsigned long i = 1; i <= PathNum; ++i)
	{
		temp1 = Mylist[1];
		Mylist[1] = *TailPtr;
		*TailPtr = temp1;
		TailPtr--;
		unsigned long j = 1;
		while(2*j <= PathNum - i){
			if(2*j+1 <= PathNum-i){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
	}

	cout<<Mylist[KthNum];
	return 0;
}


 #include<bits/stdc++.h>

using namespace std;
const int maxn=5e5+10;
#define inf 0x3f3f3f3f3f3f3f3f

long long dp[805][805],dis[maxn];
int tot=0,n,m,k,b[maxn],cnt=0;

struct node{
    int u,v,w;
    friend bool operator<(const node&a,const node&b){
        return a.w<b.w;
    }
}a[maxn];

int main()
{
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=m;i++) scanf("%d %d %d",&a[i].u,&a[i].v,&a[i].w);
    sort(a+1,a+m+1);memset(dp,0x3f,sizeof(dp));
    for(int i=1;i<=min(k,m);i++) b[++cnt]=a[i].u,b[++cnt]=a[i].v;
    sort(b+1,b+cnt+1);int qwq=unique(b+1,b+cnt+1)-b-1;
    for(int i=1;i<=min(k,m);i++) {
        int from=lower_bound(b+1,b+qwq+1,a[i].u)-b,to=lower_bound(b+1,b+qwq+1,a[i].v)-b;
        dp[from][to]=dp[to][from]=a[i].w;
    }
    for(int k=1;k<=qwq;k++) for(int i=1;i<=qwq;i++) for(int j=1;j<=qwq;j++)if(dp[i][k]+dp[k][j]<dp[i][j]) dp[i][j]=dp[i][k]+dp[k][j];
    for(int i=1;i<=qwq;i++) for(int j=i+1;j<=qwq;j++) if(dp[i][j]!=inf) dis[++tot]=dp[i][j];
    sort(dis+1,dis+tot+1);
    printf("%lld\n",dis[k]);
}


#include<iostream>
using namespace std;

int main(void){
	unsigned long NodeNum;
	cin >> NodeNum;
	unsigned long EdgeNum;
	cin >> EdgeNum;
	unsigned long KthNum;
	cin >> KthNum;
	long long Path[801][801];
	for (int i = 0; i < 2*EdgeNum+1; ++i)
	{
		for (int j = 0; j < 2*EdgeNum+1; ++j)
		{
			Path[i][j] = 1000000000;
		}
	}

	int mcount = 1;
	unsigned long Index[NodeNum+1];
	for (int i = 0; i <= NodeNum; ++i){
		Index[i] = 0;
	}

	int weight;
	for (unsigned long i = 0; i < EdgeNum; ++i){
		unsigned long index1, index2;
		cin>>index1;
		cin>>index2;
		if(Index[index1] == 0){
			Index[index1] = mcount;
			mcount++;
		}

		if(Index[index2] == 0){
			Index[index2] = mcount;
			mcount++;
		}

		cin >> weight;

		Path[Index[index1]][Index[index2]] = weight;
		Path[Index[index2]][Index[index1]] = weight;
	}

	int Num = mcount-1;

	for (int i = 1; i <= Num; ++i)
	{
		Path[i][i] = 0;
	}

	for(int i = 1; i <= Num; i++){
		for (int j = 0; j <= Num; ++j)
		{
			cout<<Path[i][j]<<" ";
		}
		cout<<endl;
	}

	//Floyd's Algorithm
	for(unsigned long k = 1; k <= Num; ++k){
		for(unsigned long i = 1; i <= Num ; ++i){
			for(unsigned long j = 1; j <= Num ; ++j){
				if(Path[i][j] > Path[i][k] + Path[k][j])
					Path[i][j] = Path[i][k] + Path[k][j];
			}
		}
	}

	//Extracted
	unsigned long PathNum = Num*(Num-1)/2;
	unsigned long Mylist[PathNum+1];

	unsigned long count = 1;
	for (unsigned long i = 1; i <= Num; ++i)
	{
		for (unsigned long j = i+1; j <= Num; ++j)
		{
			Mylist[count] = Path[i][j];
			count++;
		}
	}
	// MaxHeap-sort: Build
	unsigned long temp;
	for (unsigned long i = (PathNum >> 1); i >= 1; --i)
	{
		unsigned long j = i;
		while(2*j <= PathNum){
			if(2*j+1 <= PathNum){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
		temp = 0;
	}

	// Max-Heap: Sort
	unsigned long *TailPtr = &Mylist[PathNum];
	unsigned long temp1;
	for (unsigned long i = 1; i <= PathNum; ++i)
	{
		temp1 = Mylist[1];
		Mylist[1] = *TailPtr;
		*TailPtr = temp1;
		TailPtr--;
		unsigned long j = 1;
		while(2*j <= PathNum - i){
			if(2*j+1 <= PathNum-i){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
	}

	cout<<Mylist[KthNum];
	return 0;
}


#include<iostream>
using namespace std;

class Node{
public:
	long m_value;
	long m_index1;
	long m_index2;
	Node(long value, long index1, long index2){
		m_value = value;
		m_index1 = index1;
		m_index2 = index2;
	}
	~Node(){}
};

int main(void){
	long NodeNum;
	cin >> NodeNum;
	long EdgeNum;
	cin >> EdgeNum;
	long KthNum;
	cin >> KthNum;
	long Path[2*KthNum+1][2*KthNum+1];
	for (int i = 1; i <= 2*KthNum+1; ++i)
	{
		for (int j = 1; j <= 2*KthNum+1; ++j)
		{
			Path[i][j] = 10000;
		}
	}

	long Index[NodeNum+1];
	for(int i = 0; i <= NodeNum; ++i)
		Index[i] = 0;

	Node* Memo[EdgeNum+1];
	long mcount = 1;
	long index1, index2, weight;
	for (int i = 1; i <= EdgeNum; ++i){
		cin>>index1>>index2>>weight;
		if(Index[index1] == 0){
			Index[index1] = mcount;
			mcount++;
		}

		if(Index[index2] == 0){
			Index[index2] = mcount;
			mcount++;
		}
		Memo[i] = new Node(weight,Index[index1],Index[index2]);
	}

	//MinHeap:Build
	Node* temp01;
	for (int i = (EdgeNum >> 1); i >= 1; --i)
	{
		long j = i;
		while(2*j <= EdgeNum){
			if(2*j+1 <= EdgeNum){
				if(Memo[2*j]->m_value < Memo[2*j+1]->m_value){
					temp01 = Memo[2*j];
					if(Memo[2*j]->m_value < Memo[j]->m_value){
						Memo[2*j] = Memo[j];
						Memo[j] = temp01;
						j = 2*j;
					}
					else
					{
						break;
					}
				}
				else{
					temp01 = Memo[2*j+1];
					if(Memo[2*j+1]->m_value < Memo[j]->m_value){
						Memo[2*j+1] = Memo[j];
						Memo[j] = temp01;
						j = 2*j + 1;
					}
					else{
						break;
					}
				}
			}
			else
			{
				temp01 = Memo[2*j];
				if(Memo[2*j]->m_value < Memo[j]->m_value){
					Memo[2*j] = Memo[j];
					Memo[j] = temp01;
					j = 2*j;
				}
				else
				{
					break;
				}
			}
		}
	}

	Node* Nodeptr;
	Node** Nodetail = &Memo[EdgeNum];
	Node* Memo1[KthNum+1];
	for (int i = 1; i <= KthNum; ++i)
	{
		long j = 1;
		Memo1[i] = Memo[1];
		Memo[1] = *Nodetail;
		*Nodetail = nullptr;
		Nodetail--;
		while(2*j <= EdgeNum - i){
			if(2*j+1 <= EdgeNum - i){
				if(Memo[2*j]->m_value < Memo[2*j+1]->m_value){
					temp01 = Memo[2*j];
					if(Memo[2*j]->m_value < Memo[j]->m_value){
						Memo[2*j] = Memo[j];
						Memo[j] = temp01;
						j = 2*j;
					}
					else{
						break;
					}
				}
				else{
					temp01 = Memo[2*j+1];
					if(Memo[2*j+1]->m_value < Memo[j]->m_value){
						Memo[2*j+1] = Memo[j];
						Memo[j] = temp01;
						j = 2*j + 1;
					}
					else{
						break;
					}
				}
			}
			else{
				temp01 = Memo[2*j];
				if(Memo[2*j]->m_value < Memo[j]->m_value){
					Memo[2*j] = Memo[j];
					Memo[j] = temp01;
					j = 2*j;
				}
				else{
					break;
				}
			}
		}
	}

	for (long i = 1; i <= KthNum; ++i){
		Path[Memo1[i]->m_index1][Memo1[i]->m_index2] = Memo1[i]->m_value;
		Path[Memo1[i]->m_index2][Memo1[i]->m_index1] = Memo1[i]->m_value;
	}

	int Num = mcount-1;

	for (int i = 1; i <= Num; ++i)
	{
		Path[i][i] = 0;
	}

	// for(int i = 1; i <= Num; i++){
	// 	for (int j = 0; j <= Num; ++j)
	// 	{
	// 		cout<<Path[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	//Floyd's Algorithm
	for( int k = 1; k <= Num; ++k){
		for(int i = 1; i <= Num ; ++i){
			for(int j = 1; j <= Num ; ++j){
				if(Path[i][j] > Path[i][k] + Path[k][j])
					Path[i][j] = Path[i][k] + Path[k][j];
			}
		}
	}

	//Extracted
	long PathNum = Num*(Num-1)/2;
	long Mylist[PathNum+1];

	long count = 1;
	for (long i = 1; i <= Num; ++i)
	{
		for (long j = i+1; j <= Num; ++j)
		{
			Mylist[count] = Path[i][j];
			count++;
		}
	}
	// MaxHeap-sort: Build
	long temp;
	for (long i = (PathNum >> 1); i >= 1; --i)
	{
		long j = i;
		while(2*j <= PathNum){
			if(2*j+1 <= PathNum){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
		temp = 0;
	}

	// Max-Heap: Sort
	long *TailPtr = &Mylist[PathNum];
	long temp1;
	for (long i = 1; i <= PathNum; ++i)
	{
		temp1 = Mylist[1];
		Mylist[1] = *TailPtr;
		*TailPtr = temp1;
		TailPtr--;
		long j = 1;
		while(2*j <= PathNum - i){
			if(2*j+1 <= PathNum-i){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
	}

	cout<<Mylist[KthNum];
	return 0;
}


#include<iostream>
using namespace std;

int main(void){
	unsigned long NodeNum;
	cin >> NodeNum;
	unsigned long EdgeNum;
	cin >> EdgeNum;
	unsigned long KthNum;
	cin >> KthNum;
	static long long Path[900][900];
	for (int i = 0; i < 2*EdgeNum+1; ++i)
	{
		for (int j = 0; j < 2*EdgeNum+1; ++j)
		{
			Path[i][j] = 10000;
		}
	}

	int mcount = 1;
	unsigned long Index[NodeNum+1];
	for (int i = 0; i <= NodeNum; ++i){
		Index[i] = 0;
	}

	int weight;
	for (unsigned long i = 0; i < EdgeNum; ++i){
		unsigned long index1, index2;
		cin>>index1;
		cin>>index2;
		if(Index[index1] == 0){
			Index[index1] = mcount;
			mcount++;
		}

		if(Index[index2] == 0){
			Index[index2] = mcount;
			mcount++;
		}

		cin >> weight;

		Path[Index[index1]][Index[index2]] = weight;
		Path[Index[index2]][Index[index1]] = weight;
	}

	int Num = mcount-1;

	for (int i = 1; i <= Num; ++i)
	{
		Path[i][i] = 0;
	}

	// for(int i = 1; i <= Num; i++){
	// 	for (int j = 0; j <= Num; ++j)
	// 	{
	// 		cout<<Path[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	//Floyd's Algorithm
	for( int k = 1; k <= Num; ++k){
		for(int i = 1; i <= Num ; ++i){
			for(int j = 1; j <= Num ; ++j){
				if(Path[i][j] > Path[i][k] + Path[k][j])
					Path[i][j] = Path[i][k] + Path[k][j];
			}
		}
	}

	//Extracted
	unsigned long PathNum = Num*(Num-1)/2;
	unsigned long Mylist[PathNum+1];

	unsigned long count = 1;
	for (unsigned long i = 1; i <= Num; ++i)
	{
		for (unsigned long j = i+1; j <= Num; ++j)
		{
			Mylist[count] = Path[i][j];
			count++;
		}
	}
	// MaxHeap-sort: Build
	unsigned long temp;
	for (unsigned long i = (PathNum >> 1); i >= 1; --i)
	{
		unsigned long j = i;
		while(2*j <= PathNum){
			if(2*j+1 <= PathNum){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
		temp = 0;
	}

	// Max-Heap: Sort
	unsigned long *TailPtr = &Mylist[PathNum];
	unsigned long temp1;
	for (unsigned long i = 1; i <= PathNum; ++i)
	{
		temp1 = Mylist[1];
		Mylist[1] = *TailPtr;
		*TailPtr = temp1;
		TailPtr--;
		unsigned long j = 1;
		while(2*j <= PathNum - i){
			if(2*j+1 <= PathNum-i){
				if(Mylist[2*j] < Mylist[2*j+1] ){
					temp = Mylist[2*j+1];
					if(Mylist[j] < temp){
						Mylist[2*j+1] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j+1;
					}
					else{
						break;
					}
				}
				else{
					temp = Mylist[2*j];
					if(Mylist[j] < temp){
						Mylist[2*j] = Mylist[j];
						Mylist[j] = temp;
						j = 2*j;
					}
					else{
						break;
					}
				}
			}
			else{
				if(Mylist[j] < Mylist[2*j]){
					temp = Mylist[j];
					Mylist[j] = Mylist[2*j];
					Mylist[2*j] = temp;

					j = 2*j;
				}
				else{
					break;
				}
			}
		}
	}

	cout<<Mylist[KthNum];
	return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K, b[MAX], cnt;
ll g[1005][1005], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        b[++cnt] = e[i].x, b[++cnt] = e[i].y;
    }
    sort(b+1, b+cnt+1);
    int len = unique(b+1, b+cnt+1)-b-1;
    for(int i = 1; i <= K; i++){
        e[i].x = lower_bound(b+1, b+len+1, e[i].x)-b;
        e[i].y = lower_bound(b+1, b+len+1, e[i].y)-b;
        g[e[i].x][e[i].y] = g[e[i].y][e[i].x] = e[i].w;
    }
    for(int k = 1; k <= len; k++){
        for(int i = 1; i <= len; i++){
            for(int j = 1; j <= len; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int tot = 0;
    for(int i = 1; i <= len; i++){
        for(int j = i+1; j <= len; j++){
            a[++tot] = g[i][j];
        }
    }
    sort(a+1, a+tot+1);
    cout << a[K] << endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 500005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K, b[MAX], s[MAX], cnt;
ll g[1005][1005], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        b[e[i].x] = 1, b[e[i].y] = 1;
    }
    for(int i = 1; i <= n; i++){
        s[i] = b[i] + s[i-1];
    }
    int len = s[n];
    for(int i = 1; i <= K; i++){
        g[s[e[i].x]][s[e[i].y]] = g[s[e[i].y]][s[e[i].x]] = e[i].w;
    }
    for(int k = 1; k <= len; k++){
        for(int i = 1; i <= len; i++){
            for(int j = 1; j <= len; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int tot = 0;
    for(int i = 1; i <= len; i++){
        for(int j = 1; j < i; j++){
            a[++tot] = g[i][j];
        }
    }
    sort(a+1, a+tot+1);
    cout << a[K] << endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K, b[MAX], cnt;
ll g[505][505], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        b[++cnt] = e[i].x, b[++cnt] = e[i].y;
    }
    sort(b+1, b+cnt+1);
    int len = unique(b+1, b+cnt+1)-b-1;
    for(int i = 1; i <= K; i++){
        e[i].x = lower_bound(b+1, b+len+1, e[i].x)-b;
        e[i].y = lower_bound(b+1, b+len+1, e[i].y)-b;
        g[e[i].x][e[i].y] = g[e[i].y][e[i].x] = e[i].w;
    }
    for(int i = 1; i <= cnt; i++) g[i][i] = 0;
    for(int k = 1; k <= cnt; k++){
        for(int i = 1; i <= cnt; i++){
            for(int j = 1; j <= cnt; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int tot = 0;
    for(int i = 1; i <= len; i++){
        for(int j = i+1; j <= len; j++){
            a[++tot] = g[i][j];
        }
    }
    sort(a+1, a+tot+1);
    cout << a[K] << endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K, b[MAX], cnt;
ll g[1005][1005], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        b[++cnt] = e[i].x, b[++cnt] = e[i].y;
    }
    sort(b+1, b+cnt+1);
    int len = unique(b+1, b+cnt+1)-b-1;
    for(int i = 1; i <= K; i++){
        e[i].x = lower_bound(b+1, b+len+1, e[i].x)-b;
        e[i].y = lower_bound(b+1, b+len+1, e[i].y)-b;
        g[e[i].x][e[i].y] = g[e[i].y][e[i].x] = e[i].w;
    }

    for(int k = 1; k <= len; k++){
        for(int i = 1; i <= len; i++){
            for(int j = 1; j <= len; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }

    int tot = 0;
    for(int i = 1; i <= len; i++){
        for(int j = i+1; j <= len; j++){
            a[++tot] = g[i][j];
        }
    }
    sort(a+1, a+tot+1);
    cout << a[K] << endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K, b[MAX], cnt;
ll g[505][505], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        b[++cnt] = e[i].x, b[++cnt] = e[i].y;
    }
    sort(b+1, b+cnt+1);
    int len = unique(b+1, b+cnt+1)-b-1;
    for(int i = 1; i <= K; i++){
        e[i].x = lower_bound(b+1, b+len+1, e[i].x)-b;
        e[i].y = lower_bound(b+1, b+len+1, e[i].y)-b;
        g[e[i].x][e[i].y] = g[e[i].y][e[i].x] = e[i].w;
    }
//    for(int i = 1; i <= len; i++) g[i][i] = 0;
    for(int k = 1; k <= len; k++){
        for(int i = 1; i <= len; i++){
            for(int j = 1; j <= len; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int tot = 0;
    for(int i = 1; i <= len; i++){
        for(int j = i+1; j <= len; j++){
            a[++tot] = g[i][j];
        }
    }
    sort(a+1, a+tot+1);
    cout << a[K] << endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K;
ll g[505][505], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        g[e[i].x][e[i].y] = g[e[i].y][e[i].x] = e[i].w;
    }
    int p = K+1;
    while(p <= n && e[p].w == e[p-1].w) g[e[p].x][e[p].y] = g[e[p].y][e[p].x] = e[p].w, p++;
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            a[++cnt] = g[i][j];
        }
    }
    sort(a+1, a+cnt+1);
    cout << a[K] << endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K;
ll g[505][505], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        g[e[i].x][e[i].y] = g[e[i].y][e[i].x] = e[i].w;
    }
    int p = K+1;
    while(p <= m && e[p].w == e[p-1].w) g[e[p].x][e[p].y] = g[e[p].y][e[p].x] = e[p].w, p++;
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            a[++cnt] = g[i][j];
        }
    }
    sort(a+1, a+cnt+1);
    cout << a[K] << endl;

	return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
using namespace std;

struct edge{
    int x, y;
    ll w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K, b[MAX], s[MAX], cnt;
ll g[505][505], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%lld", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        b[e[i].x] = 1, b[e[i].y] = 1;
    }
    for(int i = 1; i <= n; i++){
        s[i] = b[i] + s[i-1];
    }
    int len = s[n];
    for(int i = 1; i <= K; i++){
        g[s[e[i].x]][s[e[i].y]] = g[s[e[i].y]][s[e[i].x]] = e[i].w;
    }
    for(int k = 1; k <= len; k++){
        for(int i = 1; i <= len; i++){
            for(int j = 1; j <= len; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int tot = 0;
    for(int i = 1; i <= len; i++){
        for(int j = 1; j < i; j++){
            a[++tot] = g[i][j];
        }
    }
    sort(a+1, a+tot+1);
    cout << a[K] << endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 200005
using namespace std;

struct edge{
    int x, y, w;
    friend bool operator <(edge a, edge b){
        return a.w < b.w;
    }
}e[MAX];

int n, m, K;
int g[505][505], a[MAX];

int main()
{
    cin >> n >> m >> K;
    for(int i = 1; i <= m; i++){
        scanf("%d%d%d", &e[i].x, &e[i].y, &e[i].w);
    }
    sort(e+1, e+m+1);
    memset(g, 0x3f, sizeof(g));
    for(int i = 1; i <= K; i++){
        g[e[i].x][e[i].y] = g[e[i].y][e[i].x] = e[i].w;
    }
    int p = K+1;
    while(p <= n && e[p].w == e[p-1].w) g[e[p].x][e[p].y] = g[e[p].y][e[p].x] = e[p].w, p++;
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                g[i][j] = min(g[i][k]+g[k][j], g[i][j]);
            }
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            a[++cnt] = g[i][j];
        }
    }
    sort(a+1, a+cnt+1);
    cout << a[K] << endl;

	return 0;
}


   #include <bits/stdc++.h>

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-10)

    int dx[8]={0,1,0,-1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x;
                                   				int y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}

                                            };

                                            class pa4{
                                            	public:
                                            	int x;
                                            	int y,z,w;
                                            	pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}

                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}

                                            };

                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }

                                int gcd(int v,int b){
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }

                                int mod;
int extgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
pa operator+(const pa & l,const pa & r) {
    return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
    return {l.first-r.first,l.second-r.second};
}

                int pr[200010];
                int inv[200010];

                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	wa%=warukazu;
                	if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
                	ll zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }

    			int comb(int nn,int rr){
    				if(rr<0 || rr>nn || nn<0) return 0;
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}

                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<=ert;i++){
                		pr[i]=(pr[i-1]*i)%mod;
                	}
                		inv[ert]=beki(pr[ert],mod-2,mod);
                	for(int i=ert-1;i>=0;i--){
                		inv[i]=inv[i+1]*(i+1)%mod;
                	}
                }

              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
                 //sort(ve.begin(),ve.end(),greater<int>());
//    mt19937(clock_per_sec);
  //  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

                               //----------------kokomade tenpure------------
vector<pa> G[200020];
map<pa,int> ma;
priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		if(y>yy)swap(y,yy);
			G[y].pb({yy,yyy});
			G[yy].pb({y,yyy});
			pq.push((pa3){yyy,y,yy});
		ma[mp(y,yy)]=yyy;
	}

	for(int K=0;K<k;K++){

		pa3 z;
		lll:;
		z=pq.top();
		pq.pop();
		//cout<<"   "<<z.y<<" "<<z.z<<" "<<z.x<<" "<<ma[]endl;

		if(ma[mp(z.y,z.z)]==-1) goto lll;
		//cout<<z.y<<" "<<z.z<<endl;
		ma[mp(z.y,z.z)]=-1;
		//cout<<z.y<<" "<<z.z<<" "<<z.x<<endl;
		if(K==k-1){
			cout<<z.x<<endl;
			return;
		}
		for(auto v:G[z.y]){
			int fr=z.z;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);
			if(ma.count(mp(fr,to))==false ||  ma[mp(fr,to)]>=z.x+v.second){
				pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
		}

		for(auto v:G[z.z]){
			int fr=z.y;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);

			if(!ma.count(mp(fr,to)) || ma[mp(fr,to)]>=z.x+v.second){
				pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
		}

	}

}

 signed main(){

    	       cin.tie(0);
   		ios::sync_with_stdio(false);
int n=1;

 	for(int i=0;i<n;i++){
 		solve();
 	}
  }


   #include <bits/stdc++.h>

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-10)

    int dx[8]={0,1,0,-1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x;
                                   				int y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}

                                            };

                                            class pa4{
                                            	public:
                                            	int x;
                                            	int y,z,w;
                                            	pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}

                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}

                                            };

                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }

                                int gcd(int v,int b){
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }

                                int mod;
int extgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
pa operator+(const pa & l,const pa & r) {
    return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
    return {l.first-r.first,l.second-r.second};
}

                int pr[200010];
                int inv[200010];

                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	wa%=warukazu;
                	if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
                	ll zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }

    			int comb(int nn,int rr){
    				if(rr<0 || rr>nn || nn<0) return 0;
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}

                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<=ert;i++){
                		pr[i]=(pr[i-1]*i)%mod;
                	}
                		inv[ert]=beki(pr[ert],mod-2,mod);
                	for(int i=ert-1;i>=0;i--){
                		inv[i]=inv[i+1]*(i+1)%mod;
                	}
                }

              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
                 //sort(ve.begin(),ve.end(),greater<int>());
//    mt19937(clock_per_sec);
  //  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

                               //----------------kokomade tenpure------------
vector<pa> G[200020];
set<pa> se;
priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		if(y>yy)swap(y,yy);
			G[y].pb({yy,yyy});
			G[yy].pb({y,yyy});
			pq.push((pa3){yyy,y,yy});
	}

	for(int K=0;K<k-1;K++){

		pa3 z;
		lll:;
		z=pq.top();
		pq.pop();
		if(se.count(mp(z.y,z.z))) goto lll;

		se.insert(mp(z.y,z.z));

		for(auto v:G[z.y]){
			int fr=z.z;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);

				pq.push((pa3){z.x+v.second,fr,to});
		}

		for(auto v:G[z.z]){
			int fr=z.y;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);
				pq.push((pa3){z.x+v.second,fr,to});
		}

	}
	cout<<pq.top().x<<endl;

}

 signed main(){

    	       cin.tie(0);
   		ios::sync_with_stdio(false);
int n=1;

 	for(int i=0;i<n;i++){
 		solve();
 	}
  }


   #include <bits/stdc++.h>

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-10)

    int dx[8]={0,1,0,-1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x;
                                   				int y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}

                                            };

                                            class pa4{
                                            	public:
                                            	int x;
                                            	int y,z,w;
                                            	pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}

                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}

                                            };

                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }

                                int gcd(int v,int b){
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }

                                int mod;
int extgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
pa operator+(const pa & l,const pa & r) {
    return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
    return {l.first-r.first,l.second-r.second};
}

                int pr[200010];
                int inv[200010];

                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	wa%=warukazu;
                	if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
                	ll zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }

    			int comb(int nn,int rr){
    				if(rr<0 || rr>nn || nn<0) return 0;
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}

                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<=ert;i++){
                		pr[i]=(pr[i-1]*i)%mod;
                	}
                		inv[ert]=beki(pr[ert],mod-2,mod);
                	for(int i=ert-1;i>=0;i--){
                		inv[i]=inv[i+1]*(i+1)%mod;
                	}
                }

              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
                 //sort(ve.begin(),ve.end(),greater<int>());
//    mt19937(clock_per_sec);
  //  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

                               //----------------kokomade tenpure------------
vector<pa> G[200020];
map<pa,int> ma;
priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
multiset<int>se;
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		if(y>yy)swap(y,yy);
			G[y].pb({yy,yyy});
			G[yy].pb({y,yyy});
			pq.push((pa3){yyy,y,yy});
		ma[mp(y,yy)]=yyy;
		se.insert(yyy);
	}
	while(se.size()>k)se.erase(--se.end());
	//for(int i=1;i<=n;i++)rando

	int ima=inf*10000000ll;
	for(int K=0;K<k;K++){

		pa3 z;
		lll:;
		z=pq.top();
		pq.pop();
		//cout<<"   "<<z.y<<" "<<z.z<<" "<<z.x<<" "<<ma[]endl;

		if(ma[mp(z.y,z.z)]==-1) goto lll;
		//cout<<z.y<<" "<<z.z<<endl;
		ma[mp(z.y,z.z)]=-1;
		//cout<<z.y<<" "<<z.z<<" "<<z.x<<endl;
		if(K==k-1){
			cout<<z.x<<endl;
			return;
		}

		for(auto v:G[z.y]){
			int fr=z.z;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);
			if(ima<=z.x+v.second)continue;
			if(ma.count(mp(fr,to))==false){
				se.insert(z.x+v.second);
				while(se.size()>k)se.erase(--se.end());
				if(se.size()==k) ima=*se.rbegin();
				pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
			else if(ma[mp(fr,to)]>z.x+v.second){
								pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
		}

		for(auto v:G[z.z]){
			int fr=z.y;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);
			if(ima<=z.x+v.second)continue;
			if(ma.count(mp(fr,to))==false){
				se.insert(z.x+v.second);
				while(se.size()>k)se.erase(--se.end());
				if(se.size()==k) ima=*se.rbegin();
				pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
			else if(ma[mp(fr,to)]>z.x+v.second){
								pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
		}

	}

}

 signed main(){

    	       cin.tie(0);
   		ios::sync_with_stdio(false);
int n=1;

 	for(int i=0;i<n;i++){
 		solve();
 	}
  }


   #include <bits/stdc++.h>

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-10)

    int dx[8]={0,1,0,-1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x;
                                   				int y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}

                                            };

                                            class pa4{
                                            	public:
                                            	int x;
                                            	int y,z,w;
                                            	pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}

                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}

                                            };

                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }

                                int gcd(int v,int b){
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }

                                int mod;
int extgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
pa operator+(const pa & l,const pa & r) {
    return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
    return {l.first-r.first,l.second-r.second};
}

                int pr[200010];
                int inv[200010];

                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	wa%=warukazu;
                	if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
                	ll zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }

    			int comb(int nn,int rr){
    				if(rr<0 || rr>nn || nn<0) return 0;
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}

                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<=ert;i++){
                		pr[i]=(pr[i-1]*i)%mod;
                	}
                		inv[ert]=beki(pr[ert],mod-2,mod);
                	for(int i=ert-1;i>=0;i--){
                		inv[i]=inv[i+1]*(i+1)%mod;
                	}
                }

              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
                 //sort(ve.begin(),ve.end(),greater<int>());
//    mt19937(clock_per_sec);
  //  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

                               //----------------kokomade tenpure------------
vector<pa> G[200020];
map<pa,int> ma;
priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		if(y>yy)swap(y,yy);
			G[y].pb({yy,yyy});
			G[yy].pb({y,yyy});
			pq.push((pa3){yyy,y,yy});
		ma[mp(y,yy)]=yyy;
	}

	for(int K=0;K<k;K++){

		pa3 z;
		lll:;
		z=pq.top();
		pq.pop();
		//cout<<"   "<<z.y<<" "<<z.z<<" "<<z.x<<" "<<ma[]endl;

		if(ma[mp(z.y,z.z)]==-1) goto lll;
		//cout<<z.y<<" "<<z.z<<endl;
		ma[mp(z.y,z.z)]=-1;
		//cout<<z.y<<" "<<z.z<<" "<<z.x<<endl;
		if(K==k-1){
			cout<<z.x<<endl;
			return;
		}
		for(auto v:G[z.y]){
			int fr=z.z;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);
			if(ma.count(mp(fr,to))==false ||  ma[mp(fr,to)]>z.x+v.second){
				pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
		}

		for(auto v:G[z.z]){
			int fr=z.y;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);

			if(!ma.count(mp(fr,to)) || ma[mp(fr,to)]>z.x+v.second){
				pq.push((pa3){z.x+v.second,fr,to});
				ma[mp(fr,to)]=z.x+v.second;
			}
		}

	}

}

 signed main(){

    	       cin.tie(0);
   		ios::sync_with_stdio(false);
int n=1;

 	for(int i=0;i<n;i++){
 		solve();
 	}
  }


   #include <bits/stdc++.h>

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-10)

    int dx[8]={0,1,0,-1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x;
                                   				int y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}

                                            };

                                            class pa4{
                                            	public:
                                            	int x;
                                            	int y,z,w;
                                            	pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}

                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}

                                            };

                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }

                                int gcd(int v,int b){
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }

                                int mod;
int extgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
pa operator+(const pa & l,const pa & r) {
    return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
    return {l.first-r.first,l.second-r.second};
}

                int pr[200010];
                int inv[200010];

                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	wa%=warukazu;
                	if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
                	ll zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }

    			int comb(int nn,int rr){
    				if(rr<0 || rr>nn || nn<0) return 0;
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}

                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<=ert;i++){
                		pr[i]=(pr[i-1]*i)%mod;
                	}
                		inv[ert]=beki(pr[ert],mod-2,mod);
                	for(int i=ert-1;i>=0;i--){
                		inv[i]=inv[i+1]*(i+1)%mod;
                	}
                }

              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
                 //sort(ve.begin(),ve.end(),greater<int>());
//    mt19937(clock_per_sec);
  //  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

                               //----------------kokomade tenpure------------
vector<pa> G[200020];
set<pa> se;
priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		if(y>yy)swap(y,yy);
			G[y].pb({yy,yyy});
			G[yy].pb({y,yyy});
			pq.push((pa3){yyy,y,yy});
	}

	for(int K=0;K<k;K++){

		pa3 z;
		lll:;
		z=pq.top();
		pq.pop();
		if(se.count(mp(z.y,z.z))) goto lll;
		//cout<<z.y<<" "<<z.z<<endl;
		se.insert(mp(z.y,z.z));
		if(K=k-1){
			cout<<z.x<<endl;
			return;
		}
		for(auto v:G[z.y]){
			int fr=z.z;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);

				pq.push((pa3){z.x+v.second,fr,to});
		}

		for(auto v:G[z.z]){
			int fr=z.y;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);
				pq.push((pa3){z.x+v.second,fr,to});
		}

	}

}

 signed main(){

    	       cin.tie(0);
   		ios::sync_with_stdio(false);
int n=1;

 	for(int i=0;i<n;i++){
 		solve();
 	}
  }


   #include <bits/stdc++.h>

//    #include <boost/multiprecision/cpp_int.hpp>
 #define int long long
 #define inf  1000000007
 #define pa pair<int,int>
 #define ll long long
 #define pal pair<double,double>
 #define ppap pair<pa,int>
  #define PI 3.14159265358979323846
  #define paa pair<int,char>
  #define  mp make_pair
  #define  pb push_back
  #define EPS (1e-10)

    int dx[8]={0,1,0,-1,1,1,-1,-1};
    int dy[8]={1,0,-1,0,-1,1,1,-1};
                                            using namespace std;
                                   			class pa3{
                                            	public:
                                            	int x;
                                   				int y,z;
                                            	pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
                                            	bool operator < (const pa3 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		 return z<p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                   				bool operator > (const pa3 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		 return z>p.z;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa3 &p) const{
                                            		return x==p.x && y==p.y && z==p.z;
                                            	}
                                            		bool operator != (const pa3 &p) const{
                                            			return !( x==p.x && y==p.y && z==p.z);
                                            	}

                                            };

                                            class pa4{
                                            	public:
                                            	int x;
                                            	int y,z,w;
                                            	pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
                                            	bool operator < (const pa4 &p) const{
                                            		if(x!=p.x) return x<p.x;
                                            		if(y!=p.y) return y<p.y;
                                            		if(z!=p.z)return z<p.z;
                                            		return w<p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator > (const pa4 &p) const{
                                            		if(x!=p.x) return x>p.x;
                                            		if(y!=p.y) return y>p.y;
                                            		if(z!=p.z)return z>p.z;
                                            		return w>p.w;
                                            		//return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa4 &p) const{
                                            		return x==p.x && y==p.y && z==p.z &&w==p.w;
                                            	}

                                            };
                                            class pa2{
                                            	public:
                                            	int x,y;
                                            	pa2(int x=0,int y=0):x(x),y(y) {}
                                            	pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
                                            	pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
                                            	bool operator < (const pa2 &p) const{
                                            		return y != p.y ? y<p.y: x<p.x;
                                            	}
                                            	bool operator > (const pa2 &p) const{
                                            		return x != p.x ? x<p.x: y<p.y;
                                            	}
                                            	bool operator == (const pa2 &p) const{
                                            		return abs(x-p.x)==0 && abs(y-p.y)==0;
                                            	}
                                            	bool operator != (const pa2 &p) const{
                                            		return !(abs(x-p.x)==0 && abs(y-p.y)==0);
                                            	}

                                            };

                                string itos( int i ) {
                                ostringstream s ;
                                s << i ;
                                return s.str() ;
                                }

                                int gcd(int v,int b){
                                	if(v>b) return gcd(b,v);
                                	if(v==b) return b;
                                	if(b%v==0) return v;
                                	return gcd(v,b%v);
                                }

                                int mod;
int extgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
pa operator+(const pa & l,const pa & r) {
    return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
    return {l.first-r.first,l.second-r.second};
}

                int pr[200010];
                int inv[200010];

                int beki(int wa,int rr,int warukazu){
                	if(rr==0) return 1%warukazu;
                	if(rr==1) return wa%warukazu;
                	wa%=warukazu;
                	if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
                	ll zx=beki(wa,rr/2,warukazu);
                	return (zx*zx)%warukazu;
                }

    			int comb(int nn,int rr){
    				if(rr<0 || rr>nn || nn<0) return 0;
    				int r=pr[nn]*inv[rr];
    				r%=mod;
    				r*=inv[nn-rr];
    				r%=mod;
    				return r;
    			}

                void gya(int ert){
                	pr[0]=1;
                	for(int i=1;i<=ert;i++){
                		pr[i]=(pr[i-1]*i)%mod;
                	}
                		inv[ert]=beki(pr[ert],mod-2,mod);
                	for(int i=ert-1;i>=0;i--){
                		inv[i]=inv[i+1]*(i+1)%mod;
                	}
                }

              //   cin.tie(0);
    		//	ios::sync_with_stdio(false);
    			//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
                 //sort(ve.begin(),ve.end(),greater<int>());
//    mt19937(clock_per_sec);
  //  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

                               //----------------kokomade tenpure------------
vector<pa> G[200020];
set<pa> se;
priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<m;i++){
		int y,yy,yyy;
		cin>>y>>yy>>yyy;
		if(y>yy)swap(y,yy);
			G[y].pb({yy,yyy});
			G[yy].pb({y,yyy});
			pq.push((pa3){yyy,y,yy});
	}

	for(int K=0;K<k;K++){

		pa3 z;
		lll:;
		z=pq.top();
		pq.pop();
		if(se.count(mp(z.y,z.z))) goto lll;
		//cout<<z.y<<" "<<z.z<<endl;
		se.insert(mp(z.y,z.z));
		if(K==k-1){
			cout<<z.x<<endl;
			return;
		}
		for(auto v:G[z.y]){
			int fr=z.z;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);

				pq.push((pa3){z.x+v.second,fr,to});
		}

		for(auto v:G[z.z]){
			int fr=z.y;
			int to=v.first;
			if(fr==to) continue;
			if(fr>to) swap(fr,to);
				pq.push((pa3){z.x+v.second,fr,to});
		}

	}

}

 signed main(){

    	       cin.tie(0);
   		ios::sync_with_stdio(false);
int n=1;

 	for(int i=0;i<n;i++){
 		solve();
 	}
  }


#include<iostream>
#include<vector>
#include<stack>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
#include <map>
#include <algorithm>
#define pi 3.141592653589
using namespace std;
struct triplet{
    int x,y,w;
};
bool compare(triplet a, triplet b){
    if(a.w < b.w) return true;
    return false;
}
int main(){
    int n,m,K,k;
    cin>>n>>m>>K;
    vector<triplet> edge;
    for(int i=0;i<m;i++){
        int x,y,w;
        cin>>x>>y>>w;
        edge.push_back({x,y,w});
    }
    sort(edge.begin(),edge.end(),compare);
    k = min(m,K);
    map<int,int> M;
    n = 0;
    for(int i=0;i<k;i++){
        if(M[edge[i].x] == 0) { n++;M[edge[i].x]=n;edge[i].x=n;}
        else
            edge[i].x = M[edge[i].x];

        if(M[edge[i].y] == 0) { n++;M[edge[i].y]=n;edge[i].y=n;}
        else
            edge[i].y = M[edge[i].y];
    }
    vector<vector<int>>graph(n+1,vector<int>(n+1,0));
    vector<vector<int>>cost(n+1,vector<int>(n+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) cost[i][j] = INT_MAX;
        cost[i][i] = 0;
    }
    for(int i=0;i<k;i++) {
        graph[edge[i].x][edge[i].y] = 1;
        cost[edge[i].x][edge[i].y] = edge[i].w;
        cost[edge[i].y][edge[i].x] = edge[i].w;
    }

    for(int x=1;x<=n;x++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(cost[i][x] != INT_MAX && cost[x][j] != INT_MAX && cost[i][x]+cost[x][j] < cost[i][j]) cost[i][j] = cost[i][x]+cost[x][j];
            }
        }
    }
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=n;j++){
//            cout<<cost[i][j]<<" ";
//        }
//        cout<<"\n";
//    }
    vector<int> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(cost[i][j] != INT_MAX) ans.push_back(cost[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
//    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
    cout<<ans[K-1]<<"\n";
    return 0;
}


#include<iostream>
#include<vector>
#include<stack>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
#include <map>
#include <algorithm>
#define pi 3.141592653589
using namespace std;
struct triplet{
    int x,y,w;
};
bool compare(triplet a, triplet b){
    if(a.w < b.w) return true;
    return false;
}
int main(){
    int n,m,K,k;
    cin>>n>>m>>K;
    vector<triplet> edge;
    for(int i=0;i<m;i++){
        int x,y,w;
        cin>>x>>y>>w;
        edge.push_back({x,y,w});
    }
    sort(edge.begin(),edge.end(),compare);
    k = min(m,K);
    map<int,int> M;
    n = 0;
    for(int i=0;i<k;i++){
        if(M[edge[i].x] == 0) { n++;M[edge[i].x]=n;edge[i].x=n;}
        else
            edge[i].x = M[edge[i].x];

        if(M[edge[i].y] == 0) { n++;M[edge[i].y]=n;edge[i].y=n;}
        else
            edge[i].y = M[edge[i].y];
    }
    vector<vector<int>>graph(n+1,vector<int>(n+1,0));
    vector<vector<long long int>>cost(n+1,vector<long long int>(n+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) cost[i][j] = INT_MAX;
        cost[i][i] = 0;
    }
    for(int i=0;i<k;i++) {
        graph[edge[i].x][edge[i].y] = 1;
        cost[edge[i].x][edge[i].y] = 1LL*edge[i].w;
        cost[edge[i].y][edge[i].x] = 1LL*edge[i].w;
    }

    for(int x=1;x<=n;x++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(cost[i][x] != INT_MAX && cost[x][j] != INT_MAX && cost[i][x]+cost[x][j] < cost[i][j] )
                    cost[i][j] = cost[i][x]+cost[x][j];
            }
        }
    }

    vector<long long int> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(cost[i][j] != INT_MAX) ans.push_back(cost[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[K-1]<<"\n";
    return 0;
}


#include<iostream>
#include<vector>
#include<stack>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
#include <map>
#include <algorithm>
#define pi 3.141592653589
using namespace std;
struct triplet{
    int x,y,w;
};
bool compare(triplet a, triplet b){
    if(a.w < b.w) return true;
    return false;
}
int main(){
    int n,m,K,k;
    cin>>n>>m>>K;
    vector<triplet> edge;
    for(int i=0;i<m;i++){
        int x,y,w;
        cin>>x>>y>>w;
        edge.push_back({x,y,w});
    }
    sort(edge.begin(),edge.end(),compare);
    k = min(m,K);
    map<int,int> M;
    n = 0;
    for(int i=0;i<k;i++){
        if(M[edge[i].x] == 0) { n++;M[edge[i].x]=n;edge[i].x=n;}
        else
            edge[i].x = M[edge[i].x];

        if(M[edge[i].y] == 0) { n++;M[edge[i].y]=n;edge[i].y=n;}
        else
            edge[i].y = M[edge[i].y];
    }
    vector<vector<int>>graph(n+1,vector<int>(n+1,0));
    vector<vector<long long int>>cost(n+1,vector<long long int>(n+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) cost[i][j] = INT_MAX;
        cost[i][i] = 0;
    }
    for(int i=0;i<k;i++) {
        graph[edge[i].x][edge[i].y] = 1;
        cost[edge[i].x][edge[i].y] = edge[i].w;
        cost[edge[i].y][edge[i].x] = edge[i].w;
    }

    for(int x=1;x<=n;x++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(cost[i][x] != INT_MAX && cost[x][j] != INT_MAX && cost[i][x]+cost[x][j] < cost[i][j] )
                    cost[i][j] = cost[i][x]+cost[x][j];
            }
        }
    }
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=n;j++){
//            cout<<cost[i][j]<<" ";
//        }
//        cout<<"\n";
//    }
    vector<long long int> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(cost[i][j] != INT_MAX) ans.push_back(cost[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
//    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
    cout<<ans[K-1]<<"\n";
    return 0;
}


#include<iostream>
#include<vector>
#include<stack>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
#include <map>
#include <algorithm>
#include <climits>
#define pi 3.141592653589
using namespace std;
struct triplet{
    int x,y,w;
};
bool compare(triplet a, triplet b){
    if(a.w < b.w) return true;
    return false;
}
int main(){
    int n,m,K,k;
    cin>>n>>m>>K;
    vector<triplet> edge;
    for(int i=0;i<m;i++){
        int x,y,w;
        cin>>x>>y>>w;
        edge.push_back({x,y,w});
    }
    sort(edge.begin(),edge.end(),compare);
    k = min(m,K);
    map<int,int> M;
    n = 0;
    for(int i=0;i<k;i++){
        if(M[edge[i].x] == 0) { n++;M[edge[i].x]=n;edge[i].x=n;}
        else
            edge[i].x = M[edge[i].x];

        if(M[edge[i].y] == 0) { n++;M[edge[i].y]=n;edge[i].y=n;}
        else
            edge[i].y = M[edge[i].y];
    }
    vector<vector<int>>graph(n+1,vector<int>(n+1,0));
    vector<vector<long long>>cost(n+1,vector<long long>(n+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) cost[i][j] = LLONG_MAX;
        cost[i][i] = 0;
    }
    for(int i=0;i<k;i++) {
        graph[edge[i].x][edge[i].y] = 1;
        cost[edge[i].x][edge[i].y] = 1LL*edge[i].w;
        cost[edge[i].y][edge[i].x] = 1LL*edge[i].w;
    }

    for(int x=1;x<=n;x++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(cost[i][x] != LLONG_MAX && cost[x][j] != LLONG_MAX && cost[i][x]+cost[x][j] < cost[i][j] )
                    cost[i][j] = cost[i][x]+cost[x][j];
            }
        }
    }

    vector<long long> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(cost[i][j] != LLONG_MAX) ans.push_back(cost[i][j]);
//            cout<<cost[i][j]<<" ";
        }
//        cout<<"\n";
    }
    sort(ans.begin(),ans.end());
    cout<<ans[K-1]<<"\n";
    return 0;
}


#include<iostream>
#include<vector>
#include<stack>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
#include <map>
#include <algorithm>
#include <climit>
#define pi 3.141592653589
using namespace std;
struct triplet{
    int x,y,w;
};
bool compare(triplet a, triplet b){
    if(a.w < b.w) return true;
    return false;
}
int main(){
    int n,m,K,k;
    cin>>n>>m>>K;
    vector<triplet> edge;
    for(int i=0;i<m;i++){
        int x,y,w;
        cin>>x>>y>>w;
        edge.push_back({x,y,w});
    }
    sort(edge.begin(),edge.end(),compare);
    k = min(m,K);
    map<int,int> M;
    n = 0;
    for(int i=0;i<k;i++){
        if(M[edge[i].x] == 0) { n++;M[edge[i].x]=n;edge[i].x=n;}
        else
            edge[i].x = M[edge[i].x];

        if(M[edge[i].y] == 0) { n++;M[edge[i].y]=n;edge[i].y=n;}
        else
            edge[i].y = M[edge[i].y];
    }
    vector<vector<int>>graph(n+1,vector<int>(n+1,0));
    vector<vector<long long>>cost(n+1,vector<long long>(n+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) cost[i][j] = LLONG_MAX;
        cost[i][i] = 0;
    }
    for(int i=0;i<k;i++) {
        graph[edge[i].x][edge[i].y] = 1;
        cost[edge[i].x][edge[i].y] = 1LL*edge[i].w;
        cost[edge[i].y][edge[i].x] = 1LL*edge[i].w;
    }

    for(int x=1;x<=n;x++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(cost[i][x] != LLONG_MAX && cost[x][j] != LLONG_MAX && cost[i][x]+cost[x][j] < cost[i][j] )
                    cost[i][j] = cost[i][x]+cost[x][j];
            }
        }
    }

    vector<long long> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(cost[i][j] != LLONG_MAX) ans.push_back(cost[i][j]);
//            cout<<cost[i][j]<<" ";
        }
//        cout<<"\n";
    }
    sort(ans.begin(),ans.end());
    cout<<ans[K-1]<<"\n";
    return 0;
}


#include<iostream>
#include<vector>
#include<stack>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
#include <map>
#include <algorithm>
#define pi 3.141592653589
using namespace std;
struct triplet{
    int x,y,w;
};
bool compare(triplet a, triplet b){
    if(a.w < b.w) return true;
    return false;
}
int main(){
    int n,m,K,k;
    cin>>n>>m>>K;
    vector<triplet> edge;
    for(int i=0;i<m;i++){
        int x,y,w;
        cin>>x>>y>>w;
        edge.push_back({x,y,w});
    }
    sort(edge.begin(),edge.end(),compare);
    k = min(m,K);
    map<int,int> M;
    n = 0;
    for(int i=0;i<k;i++){
        if(M[edge[i].x] == 0) { n++;M[edge[i].x]=n;edge[i].x=n;}
        else
            edge[i].x = M[edge[i].x];

        if(M[edge[i].y] == 0) { n++;M[edge[i].y]=n;edge[i].y=n;}
        else
            edge[i].y = M[edge[i].y];
    }
    vector<vector<int>>graph(n+1,vector<int>(n+1,0));
    vector<vector<int>>cost(n+1,vector<int>(n+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) cost[i][j] = INT_MAX;
        cost[i][i] = 0;
    }
    for(int i=0;i<k;i++) {
        graph[edge[i].x][edge[i].y] = 1;
        cost[edge[i].x][edge[i].y] = edge[i].w;
        cost[edge[i].y][edge[i].x] = edge[i].w;
    }

    for(int x=1;x<=n;x++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(cost[i][x] != INT_MAX && cost[x][j] != INT_MAX && cost[i][x]+cost[x][j] < cost[i][j]) cost[i][j] = cost[i][x]+cost[x][j];
            }
        }
    }

    vector<int> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(cost[i][j] != INT_MAX) ans.push_back(cost[i][j]);
        }
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
    cout<<ans[K-1]<<"\n";
    return 0;
}


#include<iostream>
#include<vector>
#include<stack>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
#include <map>
#include <algorithm>
#define pi 3.141592653589
using namespace std;
struct triplet{
    int x,y,w;
};
bool compare(triplet a, triplet b){
    if(a.w < b.w) return true;
    return false;
}
int main(){
    int n,m,K,k;
    cin>>n>>m>>K;
    vector<triplet> edge;
    for(int i=0;i<m;i++){
        int x,y,w;
        cin>>x>>y>>w;
        edge.push_back({x,y,w});
    }
    sort(edge.begin(),edge.end(),compare);
    k = min(m,K);
    map<int,int> M;
    n = 0;
    for(int i=0;i<k;i++){
        if(M[edge[i].x] == 0) { n++;M[edge[i].x]=n;edge[i].x=n;}
        else
            edge[i].x = M[edge[i].x];

        if(M[edge[i].y] == 0) { n++;M[edge[i].y]=n;edge[i].y=n;}
        else
            edge[i].y = M[edge[i].y];
    }
    vector<vector<int>>graph(n+1,vector<int>(n+1,0));
    vector<vector<long long>>cost(n+1,vector<long long>(n+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) cost[i][j] = LLONG_MAX;
        cost[i][i] = 0;
    }
    for(int i=0;i<k;i++) {
        graph[edge[i].x][edge[i].y] = 1;
        cost[edge[i].x][edge[i].y] = 1LL*edge[i].w;
        cost[edge[i].y][edge[i].x] = 1LL*edge[i].w;
    }

    for(int x=1;x<=n;x++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(cost[i][x] != LLONG_MAX && cost[x][j] != LLONG_MAX && cost[i][x]+cost[x][j] < cost[i][j] )
                    cost[i][j] = cost[i][x]+cost[x][j];
            }
        }
    }

    vector<long long> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(cost[i][j] != LLONG_MAX) ans.push_back(cost[i][j]);
//            cout<<cost[i][j]<<" ";
        }
//        cout<<"\n";
    }
    sort(ans.begin(),ans.end());
    cout<<ans[K-1]<<"\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#ifdef osayes
#include "header.cpp"
#endif // osayes
void Main();
int main() { ios::sync_with_stdio(0); cin.tie(0); while (~cin.peek()) Main(), cin.get(); return 0; }
template<typename T>bool updmin(T &a, T b) {  if (b < a) { a = b; return 1; } return 0; }
template<typename T1,typename T2,typename T3>struct _three_element_struct{T1&first;T2&second;T3&third;_three_element_struct(T1&first,T2&second,T3&third):first(first),second(second),third(third){}};
template<typename T1,typename T2,typename T3>_three_element_struct<T1,T2,T3>gettuple(tuple<T1,T2,T3>&a){return _three_element_struct<T1,T2,T3>(get<0>(a),get<1>(a),get<2>(a));}
template<typename T>
struct ShortestPath {
  vector<vector<pair<int, T>>> graph;
  ShortestPath(vector<vector<pair<int, T>>> &graph): graph(graph) {}
  void go(int k) {
    priority_queue<tuple<T, int, int>, vector<tuple<T, int, int>>, greater<tuple<T, int, int>>> q;
    for (int i = 0; i < graph.size(); i++) {
      q.push(make_tuple(0, i, i));
    }
    map<pair<int, int>, bool> visit;
    while (!q.empty()) {
      auto top = q.top();
      q.pop();
      auto three = gettuple(top);
      if (visit[{three.second, three.third}]) continue;
      visit[{three.second, three.third}] = 1;
      if (three.second < three.third) {
        if (--k == 0) {
          cout << three.first << endl;
          return;
        }
      }
      for (auto &p: graph[three.third]) {
        q.push(make_tuple(three.first + p.second, three.second, p.first));
        q.push(make_tuple(three.first + p.second, p.first, three.second));
      }
    }
  }
};
void Main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<pair<int, long long>>> graph(n);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    graph[u].push_back({v, w});
    graph[v].push_back({u, w});
  }
  ShortestPath<long long> sp(graph);
  sp.go(k);
}


#include <bits/stdc++.h>
using namespace std;
#ifdef osayes
#include "header.cpp"
#endif // osayes
void Main();
int main() { ios::sync_with_stdio(0); cin.tie(0); while (~cin.peek()) Main(), cin.get(); return 0; }
using tiii = tuple<int, int, int>;
template<typename T>bool updmin(T &a, T b) {  if (b < a) { a = b; return 1; } return 0; }
template<typename T1,typename T2,typename T3>struct _three_element_struct{T1&first;T2&second;T3&third;_three_element_struct(T1&first,T2&second,T3&third):first(first),second(second),third(third){}};
template<typename T1,typename T2,typename T3>_three_element_struct<T1,T2,T3>gettuple(tuple<T1,T2,T3>&a){return _three_element_struct<T1,T2,T3>(get<0>(a),get<1>(a),get<2>(a));}
template<typename T>
struct ShortestPath {
  vector<T> dist;
  vector<vector<pair<int, T>>> graph;
  int source;
  ShortestPath(vector<vector<pair<int, T>>> &graph, int source = 0): graph(graph), source(source) {
    dist.resize(graph.size(), numeric_limits<T>::max() >> 1);
  }
  void go() {
    dist[source] = 0;
    priority_queue<pair<T, int>> q;
    q.push({0, source});
    vector<int> vis(graph.size());
    while (!q.empty()) {
      auto top = q.top();
      q.pop();
      if (vis[top.second]) continue;
      vis[top.second] = 1;
      for (auto &p: graph[top.second]) {
        if (updmin(dist[p.first], dist[top.second] + p.second)) {
          q.push({dist[p.first], p.first});
        }
      }
    }
  }
};
void Main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<tiii> edge;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    edge.push_back(tiii{w, u, v});
  }
  sort(edge.begin(), edge.end());
  vector<int> id(n + 1, -1);
  int cur = 0;
  for (int i = 0; i < min(k, m); i++) {
    auto x = gettuple(edge[i]);
    if (id[x.second] == -1) id[x.second] = cur++;
    if (id[x.third] == -1) id[x.third] = cur++;
    x.second = id[x.second];
    x.third = id[x.third];
  }
  vector<vector<pair<int, long long>>> graph(cur);
  for (int i = 0; i < min(k, m); i++) {
    auto x = gettuple(edge[i]);
    graph[x.second].push_back({x.third, x.first});
    graph[x.third].push_back({x.second, x.first});
  }
  vector<long long> ans;
  for (int source = 0; source < cur; source++) {
    ShortestPath<long long> sp(graph, source);
    sp.go();
    for (int i = source + 1; i < cur; i++) {
      ans.push_back(sp.dist[i]);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans[k - 1] << endl;
}