import std.stdio;
import std.range;
import core.stdc.stdio;
import core.memory;
import std.typecons;
import std.string;
import std.array;
import std.algorithm;
import std.math;
import std.container;

immutable long INF = 100000000000;

void main(){
	GC.disable;

	int n,m,c;
	scanf("%d%d%d",&n,&m,&c);

	alias Tuple!(long,"cost",int,"to") edge;
	edge[][] graph = new edge[][n];

	long sum=0;
	for(int i=0;i<m;i++){
		int a,b;
		long d;
		scanf("%d%d%lld",&a,&b,&d);
		graph[a-1] ~= edge(d,b-1);
		graph[b-1] ~= edge(d,a-1);
		sum += d;
	}

	long[] dist = new long[n];
	dist[] = INF;
	auto pq = new BinaryHeap!(Array!edge,"a>b")();
	pq.insert(edge(0,0));
	while(!pq.empty){
		edge t = pq.front;
		pq.popFront;
		if(t.cost >= dist[t.to])
			continue;
		dist[t.to] = t.cost;
		foreach(e;graph[t.to]){
			if(t.cost+e.cost < dist[e.to])
				pq.insert(edge(t.cost+e.cost,e.to));
		}
	}

	long[] pCost = new long[n];
	pCost[] = 0;
	foreach(i,g;graph){
		foreach(e;g){
			if(dist[i] > dist[e.to] || (dist[i] == dist[e.to] && i < e.to))
				pCost[i] += e.cost;
		}
	}
	int[] order = new int[n];
	for(int i=0;i<n;i++) order[i]=i;
	sort(zip(dist,order));
	long w=0;
	long ans = sum;
	for(int i=0;i<n;i++){
		w=dist[i]*c;
		sum -= pCost[order[i]];
		if(i == n-1 || dist[i+1] != dist[i]){
			ans = min(ans,w+sum);
		}
	}
	ans.writeln;
}