import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*

class Dijkstra(val eg: Array<ArrayList<To>>, val start: Int) {
    private data class State(val cost: Long, val idx: Int): Comparable<State> {
        override operator fun compareTo(other: State): Int {
            if (this.cost > other.cost) return 1
            if (this.cost < other.cost) return -1
            return 0
        }
    }
    private val dist = LongArray(eg.size){LINF}
    private val pre = IntArray(eg.size){-1}
    private lateinit var path: Array<ArrayList<Int>>
    init {
        calcShortest(start)
    }
    private fun calcShortest(s: Int) {
        //val N = eg.size
        dist[s] = 0L
        val pq = PriorityQueue<State>()
        pq.add(State(dist[s], s))
        while (pq.isNotEmpty()) {
            val (d, x) = pq.poll()
            if (dist[x] < d) continue
            for (e in eg[x]) {
                val nx = e.idx
                val nd = e.cost
                if (d + nd < dist[nx]) {
                    dist[nx] = d + nd
                    pq.add(State(dist[nx], nx))
                    pre[nx] = x
                }
            }
        }
    }
    fun distance(i: Int): Long {
        return dist[i]
    }
    fun distanceAndPath(i: Int): Pair<Long, List<Int>> {
        if (!this::path.isInitialized) {
            val N = eg.size
            this.path = Array(N){ ArrayList<Int>() }
            for (t in 0 until N) {
                var x = t
                while (x >= 0) {
                    path[t].add(x)
                    x = pre[x]
                }
                path[t].reverse()
            }
        }
        return dist[i] to path[i]
    }
}

fun solve() {
    val (N, M) = rd.readIntArray()
    //val E = min(N*(N-1)/2, 1000)
    val eg = Array(N){ArrayList<To>()}
    val st = mutableSetOf<IntPair>()
    for (i in 0 until M) {
        var (a, b, c) = rd.readIntArray()
        a--; b--
        eg[a].add(To(b, c.toLong()))
        eg[b].add(To(a, c.toLong()))

        st.add(IntPair(min(a,b), max(a,b)))
    }

    for (i in 0 until N) {
        val dk = Dijkstra(eg, i)
        for (j in i+1 until N) {
            val pr = dk.distanceAndPath(j)
            val path = pr.second
            for (k in 0 until path.size-1) {
                val a = path[k]; val b = path[k+1]
                val edge = IntPair(min(a,b), max(a,b))
                if (st.contains(edge)) {
                    st.remove(edge)
                }
            }
        }
    }

    var ans = st.size
    println(ans)
}


//val rd = debug.Reader("abc", "051", "d", "sample-2")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 49944