N, M = gets.split.map(&:to_i)
dist = Array.new(N + 1){Array.new(N + 1, Float::INFINITY)}
edges = Array.new(N + 1){Hash.new}
direct = Array.new(N + 1){Hash.new}

M.times do |i|
    a, b, c = gets.split.map(&:to_i)
    edges[a][b] = c
    edges[b][a] = c
    dist[a][b] = c
    dist[b][a] = c
    direct[a][b] = true
    direct[b][a] = true
end

(1..N).each do |i|
    (1..N).each do |j|
        (1..N).each do |k|
            next if i == k || k == j
            d2 = dist[i][k] + dist[k][j]
            next if d2 == Float::INFINITY
            if dist[i][j] > d2
                dist[i][j] = d2
                direct[i][j] = false
                direct[j][i] = false
            end
        end
    end
end

sum = 0
(1..N).each do |i|
    sum += edges[i].count{|k, v| v && !direct[i][k]}
end

p sum / 2