n, m = gets.chomp.split.map(&:to_i)

INF = 10**10

d = Array.new(n, INF).map{Array.new(n,INF)}
for i in 0..n-1
    d[i][i] = 0
end

a, b, c = [], [], []

m.times do |i|
    a[i], b[i], c[i] = gets.chomp.split.map(&:to_i)
    d[a[i]-1][b[i]-1] = c[i]
    d[b[i]-1][a[i]-1] = c[i]
end

for i in 0..n-1
    for j in 0..n-1
        for k in 0..n-1
            d[j][k] = d[j][i] + d[i][k] if d[j][k] > d[j][i] + d[i][k]
        end
    end
end
#p a
#p b
#p c
#p d
ans = 0
for i in 0..m-1
    flag = false
    for j in 0..n-1
        for k in 0..n-1
            flag = true if d[j][a[i]-1] + c[i] + d[b[i]-1][k] == d[j][k]
        end
    end
    ans += 1 if flag == false
end
puts ans