N, M, *rest = $stdin.read.split.map(&:to_i)
EDGES = rest.each_slice(3).to_a

used = Array.new(M+1, 0)
$mins = Array.new(N+1){ Array.new(N+1){ [Float::INFINITY, []] }}
(N+1).times{|i| $mins[i][i] = [0, []] }
EDGES.each.with_index(1) do |(a, b, c), i|
  x, y = [a, b].sort
  $mins[x][y] = [c, [i]]
  used[i] += 1
end

def get_mins(i, j)
  if i < j
    $mins[i][j]
  else
    $mins[j][i]
  end
end
def set_mins(i, j, v)
  if i < j
    $mins[i][j] = v
  else
    $mins[j][i] = v
  end
end

for i in 1..N
  for j in i+1..N
    for k in 1..N
      d, r = get_mins(i, j)
      d1, r1 = get_mins(i, k)
      d2, r2 = get_mins(k, j)
      if d1 + d2 < d
        r.each{|e| used[e] -= 1}
        r1.each{|e| used[e] += 1}
        r2.each{|e| used[e] += 1}
        set_mins(i, j, [d1 + d2, r1 + r2])
      end
    end
  end
end
#p $mins
#p used

p used.drop(1).count(&:zero?)
