import math, sets, strutils, sequtils, parseutils

let
  nm = readLine(stdin).split(" ").map(parseInt)
  n = nm[0]
  m = nm[1]

var
  e: array[1000, tuple[a,b,c:int]]
  d: array[100, array[100, int]]

for i in 0..<m:
  let
    abc = readLine(stdin).split(" ").map(parseInt)
    a = abc[0]-1
    b = abc[1]-1
    c = abc[2]
  e[i] = (a,b,c)
  d[a][b] = c
  d[b][a] = c

const INF = 2^30
for i in 0..<n:
  for j in 0..<n:
    if i == j: continue
    if d[i][j] == 0: d[i][j] = INF

for k in 0..<n:
  for i in 0..<n:
    for j in 0..<n:
      if d[i][j] > d[i][k] + d[k][j]:
        d[i][j] = d[i][k] + d[k][j]


var ans = 0
for i in 0..<m:
  let
    a = e[i].a
    b = e[i].b
    c = e[i].c
  var s = false
  block check:
    for j in 0..<n-1:
      for k in j+1..<n:
        if d[j][a] + c + d[b][k] == d[j][k]:
          s = true
          break check
  if not s: ans += 1
echo ans
