class Array
  def warshall_floyd
    v = size

    used = Array.new(v) { Array.new(v, false) }
    dist = map(&:dup)

    v.times do |k|
      v.times do |i|
        v.times do |j|
          cost = dist[i][k] + dist[k][j]

          if dist[i][j] > cost
            used[i][k] = used[k][i] = true
            used[j][k] = used[k][j] = true
            used[i][j] = used[j][i] = false
            dist[i][j] = cost
          end
        end
      end
    end

    used
  end
end

N, M = gets.split.map(&:to_i)
graph = Array.new(N) { Array.new(N, Float::INFINITY) }

N.times do |i|
  graph[i][i] = 0
end

edges = M.times.map { gets.split.map(&:to_i) }

edges.each do |a, b, c|
  graph[a - 1][b - 1] = c
  graph[b - 1][a - 1] = c
end

used = graph.warshall_floyd

ans = 0

puts edges.count { |a, b, _| !used[a - 1][b - 1] }

