import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.ArrayBuffer

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val M = sc.nextInt()

    val E = Array.ofDim[Int](N, N)

    (0 until M) foreach { _ =>
      val a = sc.nextInt() - 1
      val b = sc.nextInt() - 1
      val c = sc.nextInt()
      E(a)(b) = c
      E(b)(a) = c
    }

    val INF = 100001
    def findPath(s: Int, t: Int): List[Int] = {
      val d = Array.fill[Int](N)(INF)

      type Edge = (Int, Int)
      val q = mutable.PriorityQueue[(Int, Edge)]()(Ordering.by[(Int, Edge), Int](_._1).reverse)
      val pre = Array.ofDim[Int](N)

      d(s) = 0
      addEdges(s)
      def addEdges(v: Int): Unit = {
        (0 until N) foreach { u =>
          if (E(v)(u) > 0) q.enqueue((E(v)(u) + d(v), v -> u))
        }
      }

      while(q.nonEmpty) {
        val (c, (v0, v)) = q.dequeue()
        if (c < d(v)) {
          d(v) = c
          pre(v) = v0
          addEdges(v)
        }
      }

      def trace(v: Int, path: List[Int]): List[Int] = v match {
        case `s` => v :: path
        case _ =>
          val u = pre(v)
          trace(u, v :: path)
      }

      trace(t, Nil)
    }

    val used = Array.ofDim[Boolean](N, N)
    for {
      i <- 0 until N -1
      j <- i + 1 until N
    } {
      val path = findPath(i, j)
      (0 until path.length - 1) foreach { k =>
        val l = k + 1
        used(path(k))(path(l)) = true
        used(path(l))(path(k)) = true
      }
    }

    val ans = (for {
      i <- 0 until N - 1
      j <- i + 1 until N
    } yield E(i)(j) > 0 && !used(i)(j)).count(identity)

    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}
