n,m = gets.chomp.split(" ").map(&:to_i)
edge = m.times.map{gets.chomp.split(" ").map(&:to_i)}
path = Array.new(n).map{Array.new(n,100000)}
ans = 0
edge.each do |i,j,k|
  path[i-1][j-1] = path[j-1][i-1] = k
end
n.times do |i|
  path[i][i] = 0
end
for i in 0..n-1
  for j in 0..n-2
    for k in i+1..n-1
      if path[j][k] > path[j][i]+path[i][k]
        path[j][k] = path[k][j] = path[j][i]+path[i][k]
      end
    end
  end
end
edge.each do |i,j,k|
  if path[i-1][j-1] < k
    ans += 1
  end
end
p ans