import sequtils,strutils, math, algorithm

var
  nm = readLine(stdin).split().map(parseInt)
  n = nm[0]
  m = nm[1]
  abc: seq[seq[int]]
  edge: seq[seq[int]]
  cnt = 0
let
  inf = 10^9
abc = @[]
edge = newSeqWith(n, newSeqWith(n, inf))

for i in 1..m:
  abc.add(readLine(stdin).split().map(parseInt))
  edge[abc[^1][0]-1][abc[^1][1]-1] = abc[i-1][2]
  edge[abc[^1][1]-1][abc[^1][0]-1] = abc[i-1][2]

for i in 1..n:
  for j in 1..n:
    if i == j:
      edge[i-1][j-1] = 0

for i in 1..n:
  for j in i+1..n:
    for k in 1..n:
      if k != i and k != j:
        if edge[i-1][j-1] >= inf:
          continue
        elif edge[i-1][j-1] > edge[i-1][k-1]+edge[k-1][j-1]:
          inc(cnt)
echo cnt