N, X = gets.split.map(&:to_i) A = gets.split.map(&:to_i) B = gets.split.map(&:to_i) C = A.map { |a| a - X } T = C.sum if T >= 0 puts 0 elsif C.max < 0 puts -1 else L = T.abs dp = Array.new(L + 1, Float::INFINITY) dp[0] = 0 C.each_with_index do |c, idx| next if c >= 0 L.downto(0) do |i| ni = i + c.abs ni = L if ni > L n_cost = dp[i] + B[idx] dp[ni] = n_cost if dp[ni] > n_cost end end puts dp[T.abs..-1].min end