import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._


  val Array(n, m, c) = readLine.trim.split(' ').map(_.toInt)
  val fields = Array.tabulate(n){_ ⇒ new Field }
  var rest = 0L
  for (_ ← 0 until m){
    val Array(a, b, d) = readLine.trim.split(' ').map(_.toInt)
    fields(a - 1).addRoute(b - 1, d)
    fields(b - 1).addRoute(a - 1, d)
    rest += d
  }
  val popped = Array.tabulate(n){_ ⇒ false}
  val distance = minDistance(fields).zipWithIndex.sortBy(_._1)
  var minCost = Long.MaxValue
  for ((x, f) ← distance) {
    popped(f) = true
    for (Route(to, d) ← fields(f).route){
      if (popped(to)) {
        rest -= d
      }
    }
    if (minCost > x * c + rest) minCost = x * c + rest
  }
  println(minCost)

  def minDistance(fields: Array[Field]): Array[Long] = {
    val queue = mutable.PriorityQueue((0, 0L): (Int, Long))(Ordering.by[(Int, Long), Long](_._2).reverse)
    val res = Array.tabulate(fields.length){_ ⇒ Long.MaxValue}.also{_(0) = 0L}
    while (queue.nonEmpty){
      val (top, distance) = queue.dequeue()
      if (res(top) == distance){
        for (Route(to, d) ← fields(top).route) {
          if (res(to) > distance + d) {
            res(to) = distance + d
            queue.enqueue((to, res(to)))
          }
        }
      }
    }
    res
  }
  class Field{
    private var mRoute: List[Route] = Nil
    def addRoute(to: Int, distance: Int): Unit = mRoute ::= Route(to, distance)
    def route: List[Route] = mRoute
  }
  case class Route(to: Int, distance: Int)
  implicit class ScopeFunc[T](val value: T) {
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

/*
 */
