import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from collections import deque INF = 10**18 def main(): n, m, k = map(int, input().split()) E = [] for i in range(m): u, v, c = map(int, input().split()) u, v = u-1, v-1 E.append((u, v, c)) def bfs(s, edge): q = deque([]) q.append(0) dist = [INF]*n dist[0] = 0 while q: v = q.popleft() if v == n-1: return dist[n-1] for c, nv in edge[v]: if dist[v]+c < dist[nv]: dist[nv] = dist[v]+c if c == 0: q.appendleft(nv) else: q.append(nv) def is_ok(x): edge = [[] for i in range(n)] for u, v, c in E: if c > x: edge[u].append((1, v)) edge[v].append((1, u)) else: edge[u].append((0, v)) edge[v].append((0, u)) d = bfs(0, edge) return d < k ng = -1 ok = 2*10**5+50 while ng+1 < ok: mid = (ng+ok)//2 if is_ok(mid): ok = mid else: ng = mid print(ok) if __name__ == '__main__': main()