N, M = gets.split.map(&:to_i)
ABCs = readlines.map{|l| l.split.map(&:to_i)}

d = ABCs.each_with_object(Array.new(N){Array.new(N, 1 << 31)}){|(a, b, c), g| g[a - 1][b - 1] = g[b - 1][a - 1] = c}
(0 ... N).each do |i|
  (0 ... N).each do |j|
    (0 ... N).each do |k|
      d[i][j] = [d[i][j], d[i][k] + d[k][j]].min
    end
  end
end
puts ABCs.count{|a, b, c| c > d[a - 1][b - 1]}
