def cal(m,n):
    if m>n:
        return 0
    else:
        return cal(2*m,n)+cal(2*m+1,n)+1


while True:
    try:
        m,n = map(eval,input().strip().split())
        if (m,n) == (0,0):
            continue
        print(cal(m,n))
    except EOFError:
        break