N, M = gets.split.map(&:to_i)
edges = readlines.map { |l| l.split.map(&:to_i) }

dp = Array.new(N) { Array.new(N, 10_000) }
edges.each do |a, b, c|
  dp[a-1][b-1] = [dp[a-1][b-1], c].min
  dp[b-1][a-1] = [dp[b-1][a-1], c].min
end

(0..N-1).each do |k|
  (0..N-1).each do |i|
    (0..N-1).each do |j|
      dp[i][j] = [dp[i][j], dp[i][k] + dp[k][j]].min
    end
  end
end

ans = M
edges.each do |a, b, c|
  shortest = false
  (0..N-1).each do |j|
    shortest = true if dp[j][a-1] + c == dp[j][b-1]
  end
  ans -= 1 if shortest
end
p ans