#include <iostream>
using namespace std;
int res = 0;
void func(int nowIndex, int lastIndex){
    if(nowIndex<=lastIndex)res++;
    if(nowIndex*2<=lastIndex)func(nowIndex*2,lastIndex);
    if(nowIndex*2+1<=lastIndex)func(nowIndex*2+1,lastIndex);
}

int main() {
    int m,n;
    while(cin>>m>>n){//n是最后一个节点的编号
        if(m*n == 0)break;
        int num = 0;
        func(m,n);
        cout<<res<<endl;
        res=0;
    }
}
// 64 位输出请用 printf("%lld")

简单递归