N, M = gets.split.map(&:to_i)
ABCs = readlines.map{|l| a, b, c = l.split.map(&:to_i); [a - 1, b - 1, c]}

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