N,M=gets.split.map(&:to_i)
MAX = 1<<30
dist = Array.new(N){Array.new(N, MAX)}
M.times do
  a, b, c = gets.split.map(&:to_i)
  dist[a-1][b-1] = dist[b-1][a-1] = c
end
used = {}
N.times do |k|
  N.times do |i|
    N.times do |j|
      if dist[i][j] > dist[i][k]+dist[k][j]
        dist[i][j] = dist[i][k]+dist[k][j]
        used[(i < k ? [i,k].inspect : [k, i].inspect)] = true
        used[(j < k ? [j,k].inspect : [k, j].inspect)] = true
      end
    end
  end
end
p M - used.keys.size