import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val Array(n, r) = readLine.trim.split(' ').map(_.toInt)
  val towns = Array.fill(n){Nil: List[(Int, Int)]}
  for (_ ← 0 until r){
    val Array(s, t, d) = readLine.trim.split(' ').map(_.toInt)
    towns(s - 1) ::= (t - 1, d)
    towns(t - 1) ::= (s - 1, d)
  }
  val heap = mutable.PriorityQueue()(Ordering.by[(Int, Int), Int](_._2).reverse)
  val maxDistanceFrom = Array.fill(n){0}
  val useWhenStartFrom = Array.fill(n){Array.fill(n){false}}
  var maxDistance = 0
  for (start ← 0 until n){
    val minDistance = Array.fill(n){Int.MaxValue}
    minDistance(start) = 0
    heap.enqueue((start, 0))
    var far = start
    while (heap.nonEmpty) {
      val (current, cost) = heap.dequeue()
      if (minDistance(current) == cost) {
        far = current
        for ((next, length) ← towns(current)) {
          if (minDistance(next) > cost + length) {
            minDistance(next) = cost + length
            heap.enqueue((next, cost + length))
          }
        }
      }
    }
    maxDistanceFrom(start) = minDistance(far)
    if (maxDistance <= minDistance(far)) {
      maxDistance = minDistance(far)
      val fars = (0 until n).filter(t ⇒ minDistance(t) == maxDistance)
      val queue = mutable.Queue[Int](fars:_*)
      fars.foreach(i ⇒ useWhenStartFrom(start)(i) = true)
      while (queue.nonEmpty) {
        val current = queue.dequeue()
        for ((next, length) ← towns(current) if minDistance(next) + length == minDistance(current) && !useWhenStartFrom(start)(next)) {
          useWhenStartFrom(start)(next) = true
          queue.enqueue(next)
        }
      }
    }
  }
  val buzzer = (0 until n).filter(t ⇒ maxDistanceFrom(t) == maxDistance)
  val quiet = (0 until n).filterNot(t ⇒ buzzer.exists(b ⇒ useWhenStartFrom(b)(t)))
  println(quiet.length)
  if (quiet.nonEmpty) println(quiet.map{_ + 1}.mkString("\n"))
}
