N, M = gets.split.map(&:to_i)
path = Array.new(N+1) { Hash.new }
abc = M.times.map do
  a, b, c = gets.split.map(&:to_i)
  path[a][b] = c
  path[b][a] = c
  [a, b, c]
end
d = Array.new(N+1) { Array.new(N+1, nil) }
(1..N).each { |i| d[i][i] = 0 }

goal = nil
(1..N).each do |s|
  ((s+1)..N).each do |g|
    next if d[s][g]
    a = [[[s], 0]]
    min = 1_000_000
    a.each do |v, k|
      path[v.last].each do |(n, kk)|
        next if kk + k > min
        next if v.include?(n)
        if n == g
          min = k + kk
          goal = v + [n]
        else
          a << [v + [n], k + kk]
        end
      end
    end
    (goal.size - 1).times do |i|
      z = 0
      zz = goal[i]
      goal[i..-1].each_cons(2) do |j, k|
        z += d[j][k] || path[j][k]
        path[zz][k] = z
        path[k][zz] = z
        d[zz][k] = z
        d[k][zz] = z
      end
    end
  end
end

p(abc.count { |a,b,c| d[a][b] < c })
