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

vias = Array.new(n+1) { Array.new(n+1) { [] } }

minimum_edges = Array.new(n+1) { []*(n+1) }
(1..n).each do |via|
  (1..n).each do |from|
    (1..n).each do |to|
      if graph[from][to] > graph[from][via] + graph[via][to]
        graph[from][to] = graph[from][via] + graph[via][to]
        vias[from][to] << via
      end
    end
  end
end

#graph.each {|l|p l}
#p '---'
#vias.each {|l|p l}

used_edges = []
(1..n).each do |i|
  (i+1..n).each do |j|
    tmp = vias[i][j].dup
    tmp.push(j)
    tmp.unshift(i)
    tmp.each_cons(2) {|l,r| used_edges.push([l,r].minmax) }
  end
end

used_edges = used_edges.uniq

#p used_edges

p m-(abc.map {|a,b,c| [a,b].minmax} & used_edges).length
