t = Array.new(10)
t.fill(2)
count = 0
a = gets.chomp.to_i
b =[]
a.times do |i|
    b[i] = gets.chomp.split(" ")
    b[i][0..3]= b[i][0..3].map{|u|u.to_i}
    if b[i][4] == "YES"
        b[i][0..3].each do |d|
            t[d]+=1  
        end
        count += 1
    else
        b[i][0..3].each {|d|t[d] = 1}
    end
end
puts t.index(2+count)