import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); ArrayList> boxes = new ArrayList<>(); boxes.add(new ArrayList<>()); boxes.get(0).add(new Box(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)); Box[] tmp = new Box[n]; for (int i = 0; i < n; i++) { tmp[i] = new Box(sc.nextInt(), sc.nextInt(), sc.nextInt()); } Arrays.sort(tmp); for (Box b : tmp) { for (int j = boxes.size() - 1; j >= 0; j--) { boolean ng = true; for (Box x : boxes.get(j)) { if (x.isSmaller(b)) { ng = false; break; } } if (!ng) { if (j == boxes.size() - 1) { boxes.add(new ArrayList<>()); } boxes.get(j + 1).add(b); break; } } } System.out.println(boxes.size() - 1); } static class Box implements Comparable { int big; int middle; int small; public Box(int[] arr) { Arrays.sort(arr); small = arr[0]; middle = arr[1]; big = arr[2]; } public Box(int a, int b, int c) { this(new int[]{a, b, c}); } public int compareTo(Box another) { if (big == another.big) { if (middle == another.middle) { return another.small - small; } else { return another.middle - middle; } } else { return another.big - big; } } public boolean isSmaller(Box another) { return big > another.big && middle > another.middle && small > another.small; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }