#include <cstdio>
#include <iostream>


using namespace std;

int node(int total,int root){
    if(root>total){
        return 0;
    }
    return 1+node(total,root*2)+node(total,root*2+1);
}

int main(){
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF){
        printf("%d\n",node(m,n));
    }
    return 0;
}