n = gets.chomp.to_i ss = [] n.times{ s = gets.chomp.chop.reverse.chop.size ss << s } p ss.group_by(&:itself).max_by{|_,v| v.size}.first # ref: https://osa.hatenablog.com/entry/2014/12/21/122603