n, m = gets.to_s.split.map{|i| i.to_i }
a, b, c = Array.new(m){ gets.to_s.split.map{|i| i.to_i-1 } }.transpose
c.map!{|t| t-1 }

vmax = Int32::MAX / 3
dist = Array.new(n) { Array.new(n) { vmax } }
n.times { |i| dist[i][i] = 0 }

m.times do |i|
  dist[a[i]][b[i]] = Math.min(dist[a[i]][b[i]], c[i])
  dist[b[i]][a[i]] = Math.min(dist[b[i]][a[i]], c[i])
end

n.times do |k|
  n.times do |i|
    n.times do |j|
      dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j])
    end
  end
end

ans = 0
m.times do |i|
  ans += 1 if dist[a[i]][b[i]] < c[i]
end

puts ans
