import sequtils,strutils

var
  nm = readLine(stdin).split().map(parseInt)
  n = nm[0]
  m = nm[1]
  abc: seq[seq[int]]
  cnt = 0
abc = @[]
for i in 1..m:
  abc.add(readLine(stdin).split().map(parseInt))

proc abc051d(graph:seq[seq[int]], a,b:int):int=
  for value in graph:
    if @[a, b] == value[0..^2] or @[b, a] == value[0..^2]:
      return value[^1]
  return 1000000

for i in 1..n:
  for j in i+1..n:
    for k in 1..n:
      if k != i and k != j:
        if abc051d(abc, i, j) == 1000000:
          continue
        elif abc051d(abc, i, j) > abc051d(abc, i, k)+abc051d(abc, k, j):
          inc(cnt)
echo cnt