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

vias = Array.new(n+1) { [0]*(n+1) }
(1..n).each do |from|
  (1..n).each do |to|
    vias[from][to] = from
  end
end

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}

def path_arr(start, goal, vias)
  return [start, goal] if vias[start][goal] == start && start != goal
  [start] + path_arr(vias[start][goal], goal, vias)
end

used_edges = []
(1..n).each do |i|
  (i+1..n).each do |j|
    used_edges.concat( path_arr(i, j, vias).each_cons(2).map {|i, j| [i,j].minmax} )
  end
end
# p used_edges

used_edges = used_edges.uniq

# p "---"

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