fun main(arg: Array<String>) {
    val INF = 1000000007
    val (N, M) = listOfInt()
    val G = Array(N) { IntArray(N) { INF } }
    val E = Array(N) { IntArray(N) }
    repeat(N) { n -> G[n][n] = 0 }
    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
    }
    repeat(N, N, N) { k, n, m ->
        G[n][m] = Math.min(G[n][m], G[n][k] + G[k][m])
    }
    val A = Array(N) { BooleanArray(N) }
    repeat(N, N, N, N) { s, t, n, m ->
        if (s != t && n != m)
            if (G[s][t] == G[s][n] + E[n][m] + G[m][t]) A[n][m] = true
    }
    var ans = 0
    repeat(N, N) { n, m ->
        if (!A[n][m] && E[n][m] != 0) ans += 1
    }
    println(ans)
}
inline fun repeat(times1: Int, times2: Int, action: (Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2) {
            action(index1, index2)
        }
}
inline fun repeat(times1: Int, times2: Int, times3: Int, action: (Int, Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2)
            for (index3 in 0 until times3) {
                action(index1, index2, index3)
            }
}
inline fun repeat(times1: Int, times2: Int, times3: Int, times4: Int, action: (Int, Int, Int, Int) -> Unit) {
    for (index1 in 0 until times1)
        for (index2 in 0 until times2)
            for (index3 in 0 until times3)
                for (index4 in 0 until times4) {
                    action(index1, index2, index3, index4)
                }
}


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] }
