import java.util.Scanner

object Main extends App{
  def warshall_floyd(d: Array[Array[Int]], v: Int) =
    for(k <- 1 to v; i <- 1 to v; j <- 1 to v){
      d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))
  }

  // input
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val m = sc.nextInt()

  val graph = Array.ofDim[Int](n+1, n+1)
  val edges = new Array[(Int, Int, Int)](m+1)
  for(i <- 1 to n; j <- 1 to n)
    if(i == j)
      graph(i)(j) = 0
    else
      graph(i)(j) = 10000000

  for(i <- 1 to m){
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()

    edges(i) = (a, b, c)
    graph(a)(b) = c
    graph(b)(a) = c
  }


  // main process
  warshall_floyd(graph, n)

  var ans = 0
  for((a, b, c) <- edges){
    var flag = false
    for(i <- 1 to n; j <- 1 to n){
      if(graph(i)(a) + c + graph(b)(j) == graph(i)(j)
        || graph(i)(b) + c + graph(a)(j) == graph(i)(j))
        flag = true
    }

    if(!flag)
      ans += 1
  }

  println(ans)
}