import heapq n,m,c=map(int,input().split()) v=[[] for i in range(n)] for i in range(m): q,w,e=map(int,input().split()) q-=1;w-=1 v[q].append((w,e));v[w].append((q,e)) x=[];heapq.heappush(x,(0,0)) y=[1<<60]*n;y[0]=0 while x: q,w=heapq.heappop(x) if y[w]q+j+c: y[i]=q+j+c heapq.heappush(x,(y[i],i)) a,b=[1<<60]*n,[1<<60]*n a[-1]=0;b[-1]=0 x=[];heapq.heappush(x,(0,n-1,0)) while x: q,w,e=heapq.heappop(x) if a[w]