import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Box[] boxes = new Box[n]; for (int i = 0; i < n; i++) { boxes[i] = new Box(sc.nextInt(), sc.nextInt(), sc.nextInt()); } Arrays.sort(boxes); int[] counts = new int[n]; int max = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (boxes[j].bigger(boxes[i])) { counts[i] = Math.max(counts[i], counts[j] + 1); max = Math.max(max, counts[i]); } } } System.out.println(max + 1); } static class Box implements Comparable { int[] arr = new int[3]; public Box(int x, int y, int z) { arr[0] = x; arr[1] = y; arr[2] = z; Arrays.sort(arr); } public int compareTo(Box another) { return arr[0] - another.arr[0]; } public boolean bigger(Box another) { for (int i = 0; i < 3; i++) { if (arr[i] >= another.arr[i]) { return false; } } return true; } } }