import algorithm, future, macros, math, sequtils, sets, strutils, tables

var
  NM = readLine(stdin).split().map(parseInt)
  N = NM[0]
  M = NM[1]
  graph = newseqWith(N, newseqWith(N, 10^12+7))
  tmp_arr: seq[seq[int]] = @[]
for i in 0..<M:
  var tmp = readLine(stdin).split().map(parseInt)
  tmp_arr.add(tmp)
  graph[tmp[0]-1][tmp[1]-1] = tmp[2]
  graph[tmp[1]-1][tmp[0]-1] = tmp[2]
var tmp = graph
for i in 0..<N:
  for j in 0..<N:
    for k in 0..<N:
      graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

var count = 0
for arr in tmp_arr:
  if graph[arr[0]-1][arr[1]-1] < arr[2]:
    count.inc()

echo count