n = int(input()) a = [] for i in range(n): a.append(list(map(int,input().strip().split()))) # 保证 a < b for nood in a: if nood[0] > nood[1]: tmp = nood[0] nood[0] = nood[1] nood[1] = tmp # 降序排序 a.sort(reverse=True) res = [] for i in range(n): t = a[i][0] count = 1 for j in range(i+1,n): if t >= a[j][1]: count += 1 # 记录面条数量 t = a[j][0] res.append(count) print(max(res))