fun main(args: Array<String>) {
  val (N, M) = readLine()!!.split(" ").map(String::toInt)

  val a = IntArray(M)
  val b = IntArray(M)
  val c = IntArray(M)

  (0 until M).forEach { i ->
    val abc = readLine()!!.split(" ").map(String::toInt)
    a[i] = abc[0] - 1
    b[i] = abc[1] - 1
    c[i] = abc[2] - 1
  }

  val MAX = 999999999
  val dist = Array(N, { Array<Int>(N, { MAX }) })
  (0 until N).forEach { i -> dist[i][i] = 0 }

  (0 until M).forEach { i ->
    dist[a[i]][b[i]] = Math.min(dist[a[i]][b[i]], c[i])
    dist[b[i]][a[i]] = Math.min(dist[b[i]][a[i]], c[i])
  }

  (0 until N).forEach { k ->
    (0 until N).forEach { i -> 
      (0 until N).forEach { j ->
        dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j])
      }
    }    
  }

  var ans = M
  (0 until M).forEach { i ->
    var shortest = false
    (0 until N).forEach { j ->
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
        shortest = true
      }
    }
    if (shortest) {
      ans = ans - 1
    }
  }

  println(ans)
}

