N, M, *rest = $stdin.read.split.map &:to_i
E = []
D = Array.new(N+1){ Array.new(N+1, Float::INFINITY) }
rest.each_slice(3) do |a, b, c|
  D[a][b] = c
  D[b][a] = c
  E.push([a, b])
end
U = Array.new(N+1){ Array.new(N+1) }

(1..N).each do |b|
  (1..N).each do |a|
    (1..N).each do |c|
      newd = D[a][b] + D[b][c]
      if newd < D[a][c]
        D[a][c] = newd
        a < b ? U[a][b] = true : U[b][a] = true
        b < c ? U[b][c] = true : U[c][b] = true
      else
        a < c ? U[a][c] = true : U[c][a] = true
      end
    end
  end
end

p E.count{|a, b| aa, bb = [a, b].sort; !U[aa][bb]}
