from fractions import Fraction from collections import defaultdict n = int(input()) d = defaultdict(int) now = 0 for i in range(n): l, r = map(int,input().split()) g = 1 while g < l: g *= 2 #print(g,l,r) assert l <= g assert 2*l > g if r >= g and r <= 2*g: now += 1 d[Fraction(r, g)] -= 1 if 2*l >= g and 2*l <= 2*g: d[Fraction(2*l, g)] += 1 if 2*r >= g and 2*r <= 2*g: d[Fraction(2*r, g)] -= 1 if 4*l >= g and 4*l <= 2*g: d[Fraction(4*l, g)] += 1 if 4*r >= g and 4*r <= 2*g: d[Fraction(4*r, g)] -= 1 ans = now for i, c in sorted(d.items()): now += c #print(i,c,now) ans = max(ans, now) print(ans)