fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val dist = Array(n){IntArray(n){99999999}}
    val edge =(1..m).map{
        val (a,b,c) = readLine()!!.split(" ").map { it.toInt() }
        dist[a-1][b-1]=c
        dist[b-1][a-1]=c
        c*n*n+(a-1)*n+(b-1)
    }
    for (i in 0..n-1)dist[i][i]=0
    for(k in 0..n-1)for(i in 0..n-1)for(j in 0..n-1)
        dist[i][j] = Math.min(dist[i][j], dist[i][k]+dist[k][j])

//    dist.forEach { println(it.joinToString(",")) }
    val ans = edge.count{
        val u=it%(n*n)/n
        val v=it%n
        val w=it/(n*n)
        for(s in 0..n-1)for(t in 0..n-1){
            if(dist[s][u]+w+dist[v][t]==dist[s][t]) return@count false
        }
        return@count true
    }

    println(ans)
}