fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    val G = Array(N) { IntArray(N) }
    val E = Array(N) { IntArray(N) }
    repeat(M) {
        val (a, b, c) = listOfInt(-1, -1, 0)
        G[a][b] = c; G[b][a] = c
        E[a][b] = c; E[b][a] = c
    }
    for (k in 0 until N)
    for (n in 0 until N)
    for (m in 0 until N)
        G[n][m] = Math.min(G[n][m], G[n][k] + G[k][m])
    val A = Array(N) { IntArray(N) }
    for (s in 0 until N)
    for (t in 0 until N)
    for (n in 0 until N)
    for (m in 0 until N) {
        if (s == t) continue
        if (n == m) continue
        if (G[s][t] == G[s][n] + E[n][m] + G[m][t]) A[n][m] += 1
    }
    var ans = 0
    for (n in 0 until N)
        for (m in 0 until N) {
            if (A[n][m] == 0 && E[n][m] != 0) ans += 1
        }
    println(ans / 2)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map(String::toLong)
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
