n = int(input("")) numlist = [] nolist = [] yeslist = [] clist = list(range(10)) for i in range(n): input_line = input("").split(" ") temp = [] for i in range(4): temp.append(int(input_line[i])) #print("temp", temp) # temp = [a, b, c, d] if input_line[4] == "NO": nolist.append(temp) else: yeslist.append(temp) #print("nolist", nolist, "yeslist", yeslist) if nolist != []: for i in range(len(nolist)): for j in range(4): if nolist[i][j] in clist: clist[clist.index(nolist[i][j])] = 0 if yeslist != []: for i in range(len(yeslist)): for j in range(10): if j not in yeslist[i]: clist[j] = 0 #print(clist) print(sum(clist))