#coding:utf-8 N=input() list=[raw_input().split() for i in range(N)] no=[] yes=[] for i in list: if i[4] == 'NO': for u in i[:4]: no.append(u) else: for u in i[:4]: yes.append(u) if no and not yes: for i in range(10): if str(i) not in no: print i break elif not no and yes: for i in yes: if 2 <= yes.count(i): print i break else: for i in yes: if i not in no and len(yes)/4 <= yes.count(i): print i break