N,M,K = map(int,input().split()) board = [] for _ in range(M): u,v,c = map(int,input().split()) u-=1 v-=1 board.append((u,v,c)) from collections import deque def is_ok(x): edge = [[] for _ in range(N)] for i in range(M): u,v,c = board[i] if c > x: edge[u].append((v,1)) edge[v].append((u,1)) else: edge[u].append((v,0)) edge[v].append((u,0)) INF = float('inf') dis = [INF for _ in range(N)] q = deque() dis[0] = 0 q.append((0,0)) while q: t,now = q.popleft() if t > dis[now]: continue for next,cost in edge[now]: if dis[next] > cost + dis[now]: dis[next] = cost + dis[now] if cost == 0: q.appendleft((dis[next],next)) else: q.append((dis[next],next)) if dis[N-1] <= K -1: return True else: return False ok = 2 * 10 ** 5 ng = -1 while ok - ng > 1: x = (ng+ok)//2 if is_ok(x): ok = x else: ng = x print(ok)