//?????´????????????0???n-1?????´????????????
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#define int long long
using namespace std;

const int inf = 1e+12;

int n, m, c;
vector<int> et[100000];
vector<int> ec[100000];
int cost[100000];

int allCost;				//allCost = ??¨???????????????
map<int, int> ecost;		//ecost[x] = ??´??°x??????????????¨?????????????????????????????´??°x-1??\?????????????????¨??????????????????????????????????????????

void Dijkstra(){
	typedef pair<int, int> P;
	static priority_queue<P, vector<P>, greater<P> > que;
	int i;
	
	for( i = 0; i < n; i++ ) cost[i] = inf;
	que.push(P(0, 0));
	while(!que.empty()){
		P now = que.top();
		int dist = now.first;
		int pos = now.second;
		que.pop();
		if( cost[pos] <= dist )
			continue;
		cost[pos] = dist;
		
		for( i = 0; i < et[pos].size(); i++ ){
			int npos = et[pos][i];
			int ndist = dist + ec[pos][i];
			que.push(P(ndist, npos));
		}
	}
}

void set_allCost(){
	int i, j;
	
	//?????????2???????????????1?????¨????????±??????????????????????????????2??§?????? 
	allCost = 0;
	for( i = 0; i < n; i++ ){
		for( j = 0; j < et[i].size(); j++ ){
			allCost += ec[i][j];
		}
	}
	allCost /= 2;
}

void set_ecost(){
	int i, j;
	
	//?????????2???????????????1?????¨????????±??????????????????????????????2??§??????
	ecost[0] = 0;
	for( i = 0; i < n; i++ ){
		for( j = 0; j < et[i].size(); j++ ){
			int u = i;
			int v = et[i][j];
			int x = max(cost[u], cost[v]);
			if( ecost.find(x) == ecost.end() ){ ecost[x] = 0; }
			ecost[x] += ec[i][j];
		}
	}
	for( map<int, int>::iterator it = ecost.begin(); it != ecost.end(); it++ ){
		(*it).second /= 2;
	}
}

signed main()
{
	int i;
	
	cin >> n >> m >> c;
	for( i = 0; i < m; i++ ){
		int a, b, d;
		cin >> a >> b >> d;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
		ec[a].push_back(d);
		ec[b].push_back(d);
	}
	Dijkstra();
	set_allCost();
	set_ecost();
	
	int ans = inf;
	int cst = 0;
	
	//x?????¢?´¢??????
	for( map<int, int>::iterator it = ecost.begin(); it != ecost.end(); it++ ){
		int x = (*it).first;
		cst += (*it).second;
		ans = min(ans, allCost + c * x - cst);
	}
	cout << ans << endl;
}