N = int(input()) Boxes = [] for _ in range(N): Boxes.append(sorted(list(map(int, input().split())))) Boxes.sort() dp = [1] * N for i in range(N): for j in range(i): if all(Boxes[i][x] > Boxes[j][x] for x in range(3)): dp[i] = max(dp[i], dp[j] + 1) print(max(dp))