N, M = gets.split.map(&:to_i)
MAX = 1 << 30
dist = Array.new(N) { Array.new(N, MAX) }
graph = []
M.times do
  a, b, c = gets.split.map(&:to_i)
  graph << [a-1, b-1, c]
  dist[a - 1][b - 1] = dist[b - 1][a - 1] = c
end

N.times do |k|
  N.times do |i|
    N.times do |j|
      dist[i][j] = dist[i][k] + dist[k][j] if dist[i][j] > dist[i][k] + dist[k][j]
    end
  end
end
ans = M
graph.each do |edge|
  a,b,c = edge
  flag = false
  N.times do |s|
    flag = true if dist[s][b] == dist[a][s] + c
  end
  ans -= 1 if flag
end
p ans