#include <stdio.h>
#include <math.h>
long long getSum(long long n, long long m){
if (n<m)
return 0;
else if (n>=m && n<m*2)
return 1;
else if (n>=m*2 && n%2==0){
return getSum(n/2, m)*2;
}
else if (n>=m*2 && n%2==1){
return getSum((n-1)/2, m) + getSum((n+1)/2, m);
}
return -1;
}
int main(){
long long n, m;
while (scanf("%lld %lld", &n, &m) != EOF){
printf("%lld\n", getSum(n, m));
}
}