import math, strutils, sequtils, parseutils
proc ints:seq[int] = readLine(stdin).split().map(parseInt)

let
  nm = ints()
  n = nm[0]
  m = nm[1]

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

for i in 0..<m:
  let abc = ints()
  a[i] = abc[0]-1
  b[i] = abc[1]-1
  c[i] = abc[2]
  d[a[i]][b[i]] = c[i]
  d[b[i]][a[i]] = c[i]

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

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]

echo toSeq(0..<m).filter(proc(i: int): bool = c[i] > d[a[i]][b[i]]).len()