INF = 10**9
n,m = gets.split.map(&:to_i)

g = Array.new(n){ Array.new(n, INF) }
n.times { |i| g[i][i] = 0 }
edges = []

m.times do
  a,b,c = gets.split.map(&:to_i)
  a -= 1
  b -= 1
  g[a][b] = c
  g[b][a] = c
  edges << [a,b,c]
end

n.times do |k|
  n.times do |i|
    n.times do |j|
      dist = g[i][k] + g[k][j]
      g[i][j] = dist if g[i][j] > dist
    end
  end
end

ans = 0
edges.each do |i,j,cost|
  unused = true
  n.times do |k|
    next if i == k
    next if j == k
    
    unused = false if cost + g[j][k] == g[i][k]
    unused = false if cost + g[i][k] == g[j][k]
  end
  ans += 1 if unused
end

puts ans
