import sys from collections import deque input = sys.stdin.buffer.readline N, M, K = map(int, input().split()) G = [[] for _ in range(N)] for _ in range(M): u, v, c = map(int, input().split()) u -= 1 v -= 1 G[u].append((v, c)) G[v].append((u, c)) INF = 2 * 10 ** 5 + 1 def is_possible(m: int): d = deque([0]) dist = [INF] * N dist[0] = 0 while d: v = d.pop() for x, c in G[v]: dx = dist[v] if c >= m: dx += 1 if dist[x] <= dx: continue dist[x] = dx if c >= m: d.appendleft(x) else: d.append(x) return dist[N - 1] < K l, r = 0, INF while r - l > 1: m = (r + l) // 2 if is_possible(m): r = m else: l = m print(l)