import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; /* とりあえず総当たり */ public class Main { private static int n; private static long[][] boxes; private static int max; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = Integer.parseInt(sc.next()); boxes = new long[n][3]; for (int i = 0; i < n; i++) { boxes[i][0] = Long.parseLong(sc.next()); boxes[i][1] = Long.parseLong(sc.next()); boxes[i][2] = Long.parseLong(sc.next()); Arrays.sort(boxes[i]); } sc.close(); Arrays.sort(boxes, new Comparator() { @Override public int compare(long[] o1, long[] o2) { if (o1[0] < o2[0] && o1[1] < o2[1] && o1[2] < o2[2]) { return -1; } else if (o1[0] > o2[0] && o1[1] > o2[1] && o1[2] > o2[2]) { return 1; } return 0; } }); max = 1; nest(0, 1); System.out.println(max); } private static void nest(int index, int count) { for (int i = index + 1; i < n; i++) { if (isIn(index, i)) { nest(i, count + 1); } } if (count > max) { max = count; } } private static boolean isIn(int innerIndex, int outerIndex) { long[] inner = boxes[innerIndex]; long[] outer = boxes[outerIndex]; return inner[0] < outer[0] && inner[1] < outer[1] && inner[2] < outer[2]; } }