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]]
  g: 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)
  g[a][b] = c
  g[b][a] = c

var
  d: array[100, array[100, int]]
  fp = initSet[int](2^7)
proc dest(a,b:int):int =
  fp.incl(a)
  if a == b:
    return 0
  if d[a][b] > 0:
    return d[a][b]

  result = 1000*100+1
  for i in 0..<n:
    if i == a: continue
    if i in fp: continue
    if g[a][i] > 0:
      var dd = g[a][i]
      if i != b: dd += dest(i, b)
      if result > dd: result = dd
    fp.excl(i)
  fp.excl(a)

for i in 0..<n-1:
  for j in i+1..<n:
    d[i][j] = dest(i,j)
    d[j][i] = d[i][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
        if d[j][b] + c + d[a][k] == d[j][k]:
          s = true
        if s: break check
  if not s: ans += 1
echo ans
