#include<bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, int>P;

vector<P>E[100000];
ll d[100000];
struct st {
	int a, b, d;
}v[200000];
int main() {
	ll n, m, c; scanf("%lld%lld%lld", &n, &m, &c);
	ll sum = 0;
	rep(i, m) {
		int a, b, d; scanf("%d%d%d", &a, &b, &d); a--; b--;
		E[a].push_back(P(d, b)); E[b].push_back(P(d, a));
		v[i] = { a,b,d }; sum += d;
	}
	priority_queue<P, vector<P>, greater<P>>que;
	memset(d, 0x3f, sizeof(d));
	que.push(P(0, 0)); d[0] = 0;
	while (!que.empty()) {
		P p = que.top(); que.pop();
		if (d[p.second] != p.first)continue;
		for (P u : E[p.second]) {
			if (d[u.second] > p.first + u.first) {
				d[u.second] = p.first + u.first;
				que.push(P(d[u.second], u.second));
			}
		}
	}
	sort(v, v + m, [&](st&a, st&b) {return max(d[a.a], d[a.b]) < max(d[b.a], d[b.b]); });
	ll Min = sum, Max = 0;
	rep(i, m) {
		Max = max(Max, (ll)max(d[v[i].a], d[v[i].b]));
		sum -= v[i].d;
		Min = min(Min, c*Max + sum);
	}
	printf("%lld\n", Min);
}