fun main(args: Array<String>) {
  val (N, M) = readLine()!!.split(" ").map(String::toInt)

  val edges = mutableListOf<List<Int>>()
  (0 until M).forEach {
    val (a, b, c) = readLine()!!.split(" ").map(String::toInt)
    edges.add(listOf(a-1, b-1, c-1))
  }

  val MAX = 999999999
  val dists = Array(N, { Array<Int>(N, { MAX }) })
  (0 until N).forEach { dists[it][it] = 0 }

  edges.forEach { edge ->
    dists[edge[0]][edge[1]] = Math.min(dists[edge[0]][edge[1]], edge[2])
    dists[edge[1]][edge[0]] = Math.min(dists[edge[1]][edge[0]], edge[2])
  }

  (0 until N).forEach { k ->
    (0 until N).forEach { i -> 
      (0 until N).forEach { j ->
        dists[i][j] = Math.min(dists[i][j], dists[i][k] + dists[k][j])
      }
    }    
  }

  var ans = 0
  (0 until M).forEach {
    if (dists[edges[it][0]][edges[it][1]] < edges[it][2]) {
      ans = ans + 1
    }
  }

  println(ans)
}

