import java.util.*; public class NumGuess{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] nums = new String[10]; for (int i = 0; i < 10; i++) { nums[i] = "none"; } int s = sc.nextInt(); for (int i = 0; i < s; i++) { int[] ansNums = new int[4]; for (int j = 0; j < 4; j++) { ansNums[j] = sc.nextInt(); } String ans = sc.next(); Arrays.sort(ansNums); if (ans.equals("NO")) { for (int index : ansNums) { nums[index] = "false"; } } else { for (int j = 0; j < 10; j++) { if (Arrays.binarySearch(ansNums, j) < 0) { nums[j] = "false"; } else { if (!nums[j].equals("false")) { nums[j] = "true"; } } } } } int ans = 0; int trueIndex = Arrays.binarySearch(nums, "true"); int noneIndex = Arrays.binarySearch(nums, "none");; if (trueIndex < 0) { ans = noneIndex; } else { ans = trueIndex; } System.out.println(ans); } }