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()) edge = [[] for i in range(n)] for i in range(m): u, v, c = map(int, input().split()) u, v = u-1, v-1 edge[u].append((c, v)) edge[v].append((c, u)) def bfs(s, edge, x): 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 w, nv in edge[v]: if w > x: c = 1 else: c = 0 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): d = bfs(0, edge, x) 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()