n = int(input()) lt = [] for _ in range(n): lt.append(list(map(int, input().split()))) lt.sort() g = [1] * n for i in range(n): for j in range(i): if lt[i][1] > lt[j][1]: g[i] = max(g[i], g[j]+1) print(max(g))