N, M = gets.split.map(&:to_i)
d = N.times.map{N.times.map{100000}}
N.times{|i| d[i][i] = 0}
ABCs = readlines.map do |l|
  a, b, c = l.split.map(&:to_i)
  a -= 1; b -= 1
  d[a][b] = c
  d[b][a] = c
  [a, b, c]
end
N.times do |i|
  N.times do |j|
    N.times do |k|
      d[i][j] = [d[i][j], d[i][k] + d[k][j]].min
    end
  end
end
puts ABCs.count{|a, b, c| d[a][b] < c}
