import sequtils,strutils, math

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

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

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

for i in 1..n:
  for j in 1..n:
    for k in 1..n:
      dist[i-1][j-1] = min(dist[i-1][j-1], dist[i-1][k-1]+dist[k-1][j-1])

for e in edges:
  var used = false
  for i in 1..n:
    for j in 1..n:
      if dist[i-1][j-1]==dist[i-1][e[0]] + e[2] + dist[e[1]][j-1]:
        used = true
  if used == false:
    inc(cnt)

echo cnt