n, m = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1) { [10**12]*(n+1) }
abc.each do |a, b, c|
  graph[a][b] = c
  graph[b][a] = c
end

(1..n).each do |i|
  graph[i][i]=0
end

INF=10**12
result = 0
(1..n).each do |via|
  (1..n).each do |from|
    (1..n).each do |to|
      if graph[from][to]!=INF && graph[from][to] > graph[from][via] + graph[via][to]
        result += 1
        graph[to][from] = graph[from][to] = graph[from][via] + graph[via][to]
      end
    end
  end
end

p result