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^9+7))
  ans = newseqWith(N, newseqWith(N, 0))

for i in 0..<M:
  var tmp = readLine(stdin).split().map(parseInt)
  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 i in 0..<N:
  for j in 0..<N:
    if i != j:
      if graph[i][j] < tmp[i][j] and tmp[i][j] != 10^9+7:
        count.inc()
# for i in 0..<N:
#   echo graph[i]
# echo "=========="
# for i in 0..<N:
#     echo tmp[i]
echo count div 2