import sys input = sys.stdin.readline from collections import deque N,M,K=map(int,input().split()) E=[[] for i in range(N)] for i in range(M): u,v,c=map(int,input().split()) u-=1 v-=1 E[u].append((v,c)) E[v].append((u,c)) OK=10**6 NG=0 while OK>NG+1: mid=(OK+NG)//2 Q=deque([0]) ANS=[1<<30]*N ANS[0]=0 while Q: x=Q.popleft() for to,c in E[x]: if c>=mid: if ANS[to]>ANS[x]+1: ANS[to]=ANS[x]+1 Q.append(to) else: if ANS[to]>ANS[x]: ANS[to]=ANS[x] Q.appendleft(to) if ANS[N-1]>=K: NG=mid else: OK=mid print(NG)