h = Hash.new{0} gets gets.split.each{|s|h[s.to_i]+=1} p h.map{|a,b|[b,a]}.sort[-1][1]