from collections import deque import sys input = sys.stdin.readline n, m, k = map(int, input().split()) edges = [[] for _ in range(n)] for _ in range(m): u, v, c = map(int, input().split()) u -= 1 v -= 1 edges[u].append((v, c)) edges[v].append((u, c)) def ok(x): dist = [10 ** 6] * n queue = deque() queue.append((0, 0)) dist[0] = 0 while queue: pos, d = queue.popleft() if dist[pos] != d: continue for npos, c in edges[pos]: if c >= x: if dist[npos] > d + 1: dist[npos] = d + 1 queue.append((npos, d + 1)) else: if dist[npos] > d: dist[npos] = d queue.appendleft((npos, d)) return dist[n - 1] < k l = 0 r = 200200 while r - l > 1: mid = (r + l) // 2 if ok(mid): r = mid else: l = mid print(l)