fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val minCost = Array(n + 1) { Array(n + 1) { Long.MAX_VALUE / 10 } }
    (1..n).forEach { minCost[it][it] = 0 }
    val branches = mutableListOf<Triple<Int, Int, Int>>()
    for (i in 1..m) {
        val (a, b, c) = readLine()!!.split(" ").map(String::toInt)
        branches.add(Triple(a, b, c))
        minCost[a][b] = c.toLong()
        minCost[b][a] = c.toLong()
    }
    for (i in 1..n)
        for (j in 1..n)
            for (k in 1..n)
                minCost[i][k] = Math.min(minCost[i][k], minCost[i][j] + minCost[j][k])

    branches.filter { minCost[it.first][it.second] != it.third.toLong() }
    println(branches.filter { minCost[it.first][it.second] != it.third.toLong() }.size)
}