count = gets.chomp.to_i list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] count.times do array = gets.split.map(&:to_s) if arg =~ /^[0-9]+$/ array.each{|arg| array[-1] == "YES" ? list << arg.to_i : list.delete(arg.to_i)} end end puts list.uniq.sort{|x,y| list.count(y) <=> list.count(x) }[0]