import sys def solve(): N = int(input()) hako = [sorted([int(i) for i in input().split()]) for j in range(N)] hako.sort() inf = 10**9 dp = [1] * N for i in range(N - 2, -1, -1): for j in range(i + 1, N): if is_larger(hako[i], hako[j]): dp[i] = max(dp[i], dp[j] + 1) ans = max(dp) print(ans) def is_larger(a, b): return all(ai < bi for ai, bi in zip(a, b)) def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None if __name__ == '__main__': solve()