gets counts = gets.split.map(&:to_i).tally puts counts.max_by { |value, count| [count, value] }[0]