gets.to_i w_list = gets.to_s.split(" ").map(&:to_i).uniq.map{|n| ["W", n] } gets.to_i b_list = gets.to_s.split(" ").map(&:to_i).uniq.map{|n| ["B", n] } result_list = (w_list + b_list).sort{|a, b| b[1] <=> a[1]}.uniq{|n| n[1]} count = 1 result_list.each_cons(2){|n1, n2| count += 1 if !n1[0].eql? n2[0]} if result_list.length != 1 p count