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