N, M = gets.split.map(&:to_i)
path = Array.new(N+1) { Hash.new }
abc = M.times.map do
  a, b, c = gets.split.map(&:to_i)
  path[a][b] = c
  path[b][a] = c
  [a, b]
end
used = []
d = Array.new(N+1) { Array.new(N+1, nil) }

(1..(N-1)).each do |s|
  ((s+1)..N).each do |g|
    next if d[s][g]
    a = [[[s], 0]]
    goal = nil
    min = 1_000_000
    a.each do |v, k|
      path[v.last].each do |(n, kk)|
        next if kk + k > min
        next if v.include?(n)
        if n == g
          min = k + kk
          goal = v + [n]
        elsif d[n][g] && k + kk + d[n][g] < min
          min = k + kk + d[n][g]
          goal = v + [n, g]
        end
        a << [v + [n], k + kk]
      end
    end
    goal.each_cons(2) do |i, j|
      used << [i, j]
    end
    (goal.size - 1).times do |i|
      z = 0
      goal[i..-1].each_cons(2) do |j, k|
        z += d[j][k] || path[j][k]
        d[j][k] = z
        d[k][j] = z
      end
    end
  end
end

used.uniq.each do |i,j|
  abc.delete([i,j])
  abc.delete([j,i])
end

p abc.size

