n = int(input()) H = [] for _ in range(n): L = list(map(int, input().split())) L.sort() H.append(L) H.sort(key=lambda x: (x[0], x[1], x[2])) DP = [0 for _ in range(n)] DP[n - 1] = 1 for i in range(n - 2, -1, -1): res = 1 xi, yi, zi = H[i] for j in range(i + 1, n): xj, yj, zj = H[j] if xi < xj and yi < yj and zi < zj: res = max(res, DP[j] + 1) DP[i] = res print(max(DP))