def calc_score(box, i): global score for j in range(i+1, len(box)): if box[i][0] < box[j][0] and box[i][1] < box[j][1] and box[i][2] < box[j][2]: score[j] = max(score[j], score[i] + 1) return N = int(input()) box = [] for i in range(N): tmp = list(map(int, input().split())) tmp.sort() box.append(tmp) box.sort(key=lambda x:x[2]) score = [1 for i in range(N)] for i in range(N): if score[i] == 1: calc_score(box, i) print(max(score))