The year 2015 is almost over.Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 201510 = 111110111112. Note that he doesn't care about the number of zeros in the decimal representation.Limak chose some interval of years. He is going to count all years from this interval that have exactly one zero in the binary representation. Can you do it faster?Assume that all positive integers are always written without leading zeros.

The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 1018) — the first year and the last year in Limak's interval respectively.

Print one integer – the number of years Limak will count in his chosen interval.

NoteIn the first sample Limak's interval contains numbers 510 = 1012, 610 = 1102, 710 = 1112, 810 = 10002, 910 = 10012 and 1010 = 10102. Two of them (1012 and 1102) have the described property.

#include<stdio.h>
long long int a,b,C[6000],r;
int main(){
    int num,i,j,ans=0;
    scanf("%lld%lld",&a,&b);
    for(i=2;i<61;i++){
        long long int g=((long long int)1<<i)-1;
        for(j=0;j<i-1;j++){
            C[num++]=g-((long long int)1<<j);
        }
    }
    for(i=0;i<num;i++){
        if(a<=C[i]&&C[i]<=b){
            ans++;
        }
    }
    printf("%d",ans);
}

#include<stdio.h>
typedef long long unsigned llu;
typedef unsigned u;
llu F(llu a)
{
	if(a<2)return 0;
	llu x;u i=0,r=0;
	for(x=1;x<=a;x<<=1)++i;
	x>>=1;--i;r=(i*(i-1))>>1;
	for(;x>>=1;++r)if(!(x&a))break;
	a=(a&(x-1))+1;
	if(x&&a==x)++r;
	return r;
}
int main()
{
	llu a,b;
	scanf("%I64u%I64u",&a,&b);
	printf("%I64u\n",F(b)-F(a-1));
	return 0;
}

#include <stdio.h>
unsigned long long a[12800];
int top = 0;

int main()
{
    int i, j;
    unsigned long long n = (unsigned long long)-1;
    for (i = 63; i >= 1; --i) {
        n ^= (1LL << i);
        for (j = i - 2; j >= 0; --j) {
            n ^= (1LL << j);
            a[top++] = n;
            n ^= (1LL << j);
        }
    }
    unsigned long long lb, ub;
    int ans = 0;
    scanf("%I64u%I64u", &lb, &ub);
    for (i = 0; i < top; ++i) {
        if (a[i] >= lb && a[i] <= ub) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

#include<stdio.h>
int asd(__int64 l,__int64 r);
int main()
{
	__int64 i,j,k,m,n,l=0,r=0,sum,ans=0,temp;
	scanf("%I64d%I64d",&n,&m);
	for(k=1;k<=n;k*=2)
	l++;
	for(k=1;k<=m;k*=2)
	r++;
	l--;
	for(i=1;i<r;i++)
	{
		temp=0;
		sum=0;
		k=1;
		while(sum<=m)
		{
			if(sum>=n&&sum<=m&&temp>i)
			ans++;
			temp++;
			if(temp!=i)
			sum+=k;
			k*=2;
		}
	}
	printf("%I64d",ans);
	return 0;
}

#include<stdio.h>

long long int a, b;
int count=0;
void dfs(long long int n,long long int m);
int main()
{
	scanf("%I64d%I64d", &a, &b);
	dfs(1,0);
	printf("%d\n", count);
}

void dfs(long long int n,long long int m)
{
	if(n>b)
	{
		return;
	}
	if(n>=a&&n<=b&&1==m)
	{
		count++;
	}
	if(0==m)
	{
		dfs(n<<1,1);
	}
	dfs(n<<1|1,m);
}

#include<stdio.h>
int main(){
	long long int j,k,car = 1,i,sayi,a,b,n = 0,m = 0,sonuc = 0;
	scanf("%lld %lld",&a,&b);
	sayi = a;
	while(sayi>=1){
		sayi=sayi/2;
		n++;
	}
	sayi = b;
	while(sayi>=1){
		sayi=sayi/2;
		m++;
	}
	for(i = n ; i <= m ; i++){
		car = 1;
		for(k = 1 ; k <= i ; k++)
			car*=2;
		sayi = car - 1;
		for(j = 0 ; j < i-1 ; j++){
			car = 1;
			for(k = 1 ; k <= j ; k++)
				car*=2;
			if(sayi-car>=a&&sayi-car<=b)
				sonuc++;
		}
	}
	printf("%lld",sonuc);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

typedef unsigned long long int llu;

void printBits(size_t const size, void const * const ptr)
{
    unsigned char *b = (unsigned char*) ptr;
    unsigned char byte;
    int i, j;

    for (i=size-1;i>=0;i--)
    {
        for (j=7;j>=0;j--)
        {
            byte = b[i] & (1<<j);
            byte >>= j;
            printf("%u", byte);
        }
    }
    puts("");
}

int numberOfZeros(llu num, size_t const size){
	int i, result, temp;
	for(i = 0, result = 0, temp = 0; i < size*8; i++){
		if(num%2 == 0){
			temp++;
		} else {
			result += temp;
			temp = 0;
		}
		num = num >> 1;
	}

	return result;
}

int findMax(llu* b){
	int i;
	llu max = 1, mask = 3;
	max = ~(max << (sizeof(max)*8 - 2));

	for(i = 0; i < sizeof(max)*8; i++){
		if(max <= *b){
			break;
		}
		max = max >> 1;
	}

	mask = mask << (61 - i);
	for(; (max ^ mask) <= *b && i < 62; max = max ^ mask, mask = mask >> 1, i++);

	*b = max;

	return 62 - i;
}

int findMin(llu *a){
	int i;
	llu min = ~0, mask = 3;

	for(i = 0; i < sizeof(min)*8; i++){
		if((min >> 1) <= *a){
			break;
		}
		min = min >> 1;
	}

	min = min ^ 1;
	i = 0;
	for(; (min ^ mask) > *a; min = min ^ mask, mask = mask << 1, i++);

	if((min ^ mask) == *a){
		min = min ^ mask;
		i++;
		if(numberOfZeros(min, sizeof(min)) != 1){
			min = min ^ mask;
			i--;
		}
	}

	*a  = min;

	return i;
}

int len(llu a){
	int temp, i, result;

	for(i = 0, temp = 0, result = 0; i < 8*sizeof(a); i++, temp++, a = a >> 1){
		if(a%2 != 0){
			result += temp;
			temp = 0;
		}
	}

	return ++result;
}

int main(){
	llu i, a, b, ta, tb, result = 0;
	int pa, pb;

	scanf("%I64d %I64d", &a, &b);
	ta = a;
	tb = b;

	pb = findMax(&tb);
	pa = findMin(&ta);

	if(ta >= a && tb <= b && ta <= tb && pa >= 0 && pb >= 0){
		for(i = len(ta); i <= len(tb); i++){
			result += i - 1;
		}

		result -= pb;
		result -= len(ta) - 2 - pa;
	}

	printf("%I64d", result);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>

unsigned long long FindMax(unsigned  long long lData )
{
	unsigned long long lRet = 0x1;

	while( lRet < lData )
	{
		lRet <<= 1;
	}

	return lRet - 1;
}

int main()
{

	unsigned long long lInput1;
	unsigned long long lInput2;

	unsigned long long lTotalCnt = 0;
	unsigned long long lCheck;
	unsigned long long lMax ;

	unsigned long long i = 0x1;
	unsigned long long ii = 0x0;
	int iCnt = 0;

	scanf("%lld%lld",&lInput1,&lInput2);

	while( i <= lInput2 )
	{
		i <<= 1;
		iCnt++;
	}

	lMax = i - 1;

	i = 0x1;

	iCnt;
	ii = iCnt;

	while( lCheck >= lInput1 )
	{
		lCheck = lMax - i ;
		if( lCheck >= lInput1 && lCheck <= lInput2 )
		{
			lTotalCnt++;
		}
		else if( lCheck < lInput1 )
			break;

		i <<= 1;
		ii--;

		if( ii == 1 )
		{
			i = 0x1;
			lMax >>= 1;
			ii = iCnt-1;
			iCnt--;
		}
	}

	printf("%lld\n",lTotalCnt);

}

#include <stdio.h>
int main ()
{
	long long int i,j,k,sonuc=0,a,b,sayi,carpim=1,n=0,m=0;
	scanf("%lld %lld",&a,&b);
	sayi=a;
	while(sayi>=1){
		sayi=sayi/2;
		n++;
	}
	sayi=b;
	while(sayi>=1){
		sayi=sayi/2;
		m++;
	}
	for(i=n;i<=m;i++){

		carpim=1;

		for(j=1;j<=i;j++)
			carpim*=2;

		sayi=carpim-1;

		for(k=1;k<i;k++){
			carpim=1;

			for(j=1;j<k;j++)
				carpim*=2;
			if(a <= sayi-carpim && sayi-carpim <= b)
					sonuc++;
		}
	}
	printf("%lld",sonuc);
}

#include<stdio.h>
#include<math.h>

int main()
{
    long long int p,a,b,i,j,num,t,c=0;
    scanf("%I64d %I64d",&a,&b);
    for(i=63;i>=2;i--)
    {
        num=pow(2,i)-1;

            for(j=i-2;j>=0;j--)
            {
                p=pow(2,j);
                t=num-p;
                if(t>=a&&t<=b)
                    c++;

            }

    }

    printf("%I64d\n",c);

    return 0;
}

#include<stdio.h>
long long int pw(long long int x,int y)
{
    long long int i;
    long long int ans=1;
    for(i=0;i<y;i++)
    {
        ans=ans*x;
    }
    return ans;
}
long long int oton(long long int x)
{
    if(x<1){return 0;}
    return (x*(x+1))/2;
}
long long int func(long long int n)
{
    long long int i,j,k,l,m=0;

//    scanf("%lld",&n);
    l=n;
while(n>0)
{
    m++;
    n=n/2;
}
//printf("%lld\n",m);

long long int value;
long long int count=0;
for(i=2;i<=m;i++)
{
    value=0;
    for(j=1,k=m-1;j<=m;j++,k--)
    {
        if(j==i){
    //            printf("0");
         value=value+ 0*pw(2,k);}
        else {
//            printf("1");
        value=value+ 1*pw(2,k);}
    }
    //printf("  =%lld\n",value);
    if(value>l){break;}
    count++;
}
//printf("%lld",count);
count=count+oton(m-2);
//printf("\nvalue=%lld count=%lld\n",l,count);
return count;
}

int main()
{
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    long long int x,y;

    long long int ans=func(m)-func(n);
    long long int flag=0;

    while(n>0)
    {
        if(n%2==0){flag++;}
        n=n/2;
    }

    if(flag==1){ans++;}
    printf("%lld",ans);
return 0;
}

#include<stdio.h>
#include<string.h>
long long int a[4000];
void init(){
    long long int now=3,count=2,i;
    long long int tem=1;
    int d=0;
    for(i=0;i<count-1;i++){
        a[d++]=now-tem;
        tem=tem<<1;
        if(i==count-2){
            a[d++]=now-tem;
            count++;
            if(count==64)
                break;
            i=0;
            now=now<<1;
            now=now|1;
            tem=1;
        }
    }
    return ;
}
int main(){
    init();
    int ret=0;
    long long int c,b;
    scanf("%lld%lld",&c,&b);
    for(int i=0;i<4000;i++){
        if((a[i]>=c)&&(a[i]<=b))
            ret++;
    }
    if(c<=1){
        ret--;
    }
    printf("%d\n",ret);
}

#include<stdio.h>
#define LIM 9223372036854775807
//#define LIM 9223372
#define MAX 100005
int comp(const void *a,const void *b)
{
    return (int)(*(long long *)a-*(long long *)b);
}
int check(long long x)
{
  /* First x in the below expression is for the case when x is 0 */
  return x && (!(x&(x-1)));
}
long long power(long long x)
{
    if(x==0)
        return 1;
    else if(x==1)
            return 2;
    else if(x%2==0)
    {
    long long n=power(x/2);
    return n*n;
    }
    else
    {
        long long n=power(x/2);
        return n*n*2;
    }
}

long long next(long long n)
{
    double d=log(n)/log(2);
    long long x=(long long)(d);
    x=x+1;
   // printf("hi\n");
    return power(x);
}
int main()
{
   long long n,i,len,k,a,b,temp,y,x,num=0;
   long long arr[MAX];
   long long j=0;
   for(i=2;i<LIM/2;i=(2*i)+1)
   {
       x=i;
       y=next(x);
     //  printf("%lld\n",y);
       arr[j++]=x;
       for(k=y;k<LIM/2;k=k*2)
       {
       temp=x+k;
       arr[j++]=temp;
       x=temp;
     //  printf("%lld ",temp);
       }
   }
   len=j;
   //printf("len:%lld\n",len);
   qsort(arr,len,sizeof(arr[0]),comp);
  // for(j=0;j<100;j++)
    //printf("%lld\n",arr[j]);
   scanf("%I64d%I64d",&a,&b);
   for(i=0;i<len;i++)
   {
        if(arr[i]>=a&&arr[i]<=b)
        num++;
   }
   printf("%I64d\n",num);
    return 0;
}

#include <stdio.h>

int main() {
	int i, j, cnt;
	long long a, b, c, d;

	scanf("%lld%lld", &a, &b);
	cnt = 0;
	for (i = 0; (long long) i <= 60; i++) {
		c = ((long long) 1 << i) - 1;
		for (j = 0; j < i - 1; j++) {
			d = c - ((long long) 1 << j);
			if (d >= a && d <= b)
				cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
	long long unsigned int a,b,k=0,d;
	scanf("%I64u%I64u",&a,&b);
	int i , j ;
	for(i=0;i<=62;i++)
		for( j=0;j<i-1;j++)
		{
			d=pow(2,i)-1-pow(2,j);
			if(a<=d && d<=b)
				k++;
		}
	printf("%I64u",k);
	return 0;
}

#include<stdio.h>
long long int powx(long long int a,long long int b){
 long long int c,d,e;
 e=a;
 for(c=0;c<b-1;c++){
        a=a*e;
 }
return a;
}
int main(){
long long int a,b,c,x,inc,cnt=0;
long long int input,input1;
scanf("%lld%lld",&input,&input1);
for(a=64;a>=1;a--){
x=powx(2,a)-1;
inc=1;
for(b=1;b<a;b++){ //
 if((x-inc)>=input && (x-inc)<=input1){
    cnt++;
 }
 inc=inc*2;
}}

printf("%lld",cnt);

}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
long long int funk(long long int x,long long int b){
long long int m=1;

long long int a;

for(a=1;a<=b;a++){
m=m*x;
}
return m;

}
main(){

    long long int a,b,c;
  long long  int increase;
   long long int unos,unos1;
    scanf("%lld%lld",&unos,&unos1);
  long long  int x;
   long long int counter=0;

    for(a=64;a>=1;a--){
            x=funk(2,a)-1;
            increase=1;
            for(b=1;b<a;b++)
            {

                    if( ((x-increase)>=unos) && ((x-increase) <=unos1) ){
                           counter++;
                           //printf("%lld %lld %lld\n",a,x,increase);
                    }
            increase=increase*2;
            }

    }

    printf("%lld",counter);

}

#include<stdio.h>
#include<math.h>
int main(){

    int n , i, num = 0,shift,sh = 1;
    long long x,y,test1 = 2,test2,z=2;
    scanf("%lld %lld",&x,&y);
    long long base = (long long)(ceil(log2l(y)));
    while(sh <= base){
        test2 = test1;
        z = (long long)pow(2,sh);
        while(test2 <= y){
            if(test2 >= x && test2 <= y)  num++;
            z *= 2;
            test2 += z;
        }
        sh++;
        test1 = (test1<<1)+1;
    }
    printf("%d\n",num);
return 0;
}

/*#include <stdio.h>
int judge(long long x)
{
    int yushu;
    int flag=2;
    while(1)
    {
        yushu=x%2;
        if(yushu==0)
            flag--;
        if(!flag)
            return 0;
        x/=2;
        if(x<2)
        {
            if(x==0&&flag==1||x==1&&flag==2)
                return 0;
            break;
        }
    }
    return 1;
}
int main()
{
    long long a,b,num=0;
    while(scanf("%I64d%I64d",&a,&b)!=EOF)
    {
        for(; a<=b; a++)
        {
            num+=judge(a);
        }
        printf("%I64d\n",num);
    }
    return 0;
}
*/
#include <stdio.h>
#include <math.h>
int main()
{
    long long a,b,num[10000];
    int i,j,k;
    int ans=0;
    for(i=2,k=0; i<=60; i++)
    {
        for(j=i-2; j>=0; j--,k++)
        {
            num[k]=(long long)(pow(2,i)-pow(2,j)-1);
            //printf("%I64d\n",num[k]);
        }
    }
    scanf("%I64d%I64d",&a,&b);
    for(i=0; num[i]<a; i++);
    for(; num[i]<=b; i++,ans++);
    printf("%d\n",ans);
    //if(pow(2,60)>pow(10,18))
    // printf("1");
}

#include <stdio.h>
#include <stdlib.h>
#define LAST 1000000000000000001L
main()
{
	long long int year, yarr[4000];
	long long twop[66];
	long long p,pmax,a,b;
	int i,j,ind,count;
	p = 1;
	twop[0]=1;
	for (i=1; p<LAST; i++)
	{
		p = p*2;
		twop[i] = p;
	}
	pmax=i;
	ind=0;
	for (i=2; i< pmax; i++)
		for (j=i-1; j>0; j--)
			yarr[ind++] = twop[i]-1-twop[j-1];
	scanf("%lld %lld", &a, &b);
	count=0;
	for (i=0; i<ind; i++)
		if (a<= yarr[i] && b >= yarr[i]) count++;
	printf("%d\n",count);
	return 0;
}

/* https://codeforces.com/contest/611/submission/19896636 (rainboy) */
#include <stdio.h>

int main() {
	long long a, b, i, j, cnt;

	scanf("%lld%lld", &a, &b);
	cnt = 0;
	for (i = 0; i <= 60; i++) {
		long long c;

		c = (1LL << i) - 1;
		for (j = 0; j < i - 1; j++) {
			long long d;

			d = c - (1LL << j);
			if (d >= a && d <= b)
				cnt++;
		}
	}
	printf("%lld\n", cnt);
	return 0;
}

#include <stdio.h>
#include <string.h>

int main( void ) {
    unsigned long long a, b;
    scanf("%llu %llu", &a, &b);

    unsigned long long ans = 0;
    for( int i = 0; i <= 61; i++ ) {
        unsigned long long x = 0;
        for( int j = 0; j < i; j++ )
            x += (1LLu << j);

        for( int j = i+1; j <= 62; j++ ) {
            x += (1LLu << j);
            if( (x >= a) && (x <= b) ) ans++;
        }
    }

    printf("%llu\n", ans);

    return 0;
}

#include <stdio.h>

typedef unsigned long long ull;

ull x, y;
ull n = 0xFFFFFFFFFFFFFFFE;

int main() {
    int c = 0;
    int i, j;
    scanf("%llu %llu", &x, &y);
    for (i = 1; i <= 63; i++) {
        n = (1ULL << i) - 1;
        for (j = 0; j < i - 1; j++) {
            n = (1ULL << i) - 1;
            n -= 1ULL << j;
            if (n >= x && n <= y) {
                c++;
            }
        }
    }
    printf("%d\n", c);
}

#include <stdio.h>

int main()
{
	long long a, b, x = 0, y = 0, k = -1, cnt = 0;

//	freopen("input.txt", "r", stdin);

	scanf("%I64d %I64d", &a, &b);

	while (y < a) {
		cnt++;
		y = y | ((long long)1 << x);
		x--;

		if (x == -1) {
			x = ++k;
			y = (y | ((long long)1 << (x + 1))) & ~((long long)1 << x);
		} else {
			y = y & ~((long long)1 << x);
		}
	}

	cnt = 0;

	while (y <= b) {
		cnt++;
		y = y | ((long long)1 << x);
		x--;

		if (x == -1) {
			x = ++k;
			y = (y | ((long long)1 << (x + 1))) & ~((long long)1 << x);
		}
		else {
			y = y & ~((long long)1 << x);
		}
	}

	printf("%I64d", cnt);

	return 0;
}

#include<stdio.h>

long long g(int a[64],int l)
{
    long long ans,temp;
    int i;

    ans=0;
    temp=1;
    for(i=0;i<l;i++,temp*=2)
    {
        ans+=a[i]*temp;
    }

    return ans;
}

int f(long long x)
{
    int ans,i,j,l,a[64];
    long long temp;

    if(x<2)return 0;
    temp=x;
    l=0;
    while(temp)
    {
        l++;
        temp/=2;
    }
    ans=0;
    for(i=0;i<l-1;i++)
    {
        for(j=0;j<64;j++)a[j]=0;
        a[i]=0;
        for(j=i-1;j>=0;j--)a[j]=1;
        for(j=i+1;j<l;j++)
        {
            a[j]=1;
            temp=g(a,j+1);
            if(temp<=x)ans++;
        }
    }

    return ans;
}

int main()
{
    long long a,b;

    scanf("%I64d%I64d",&a,&b);
    printf("%d\n",f(b)-f(a-1));

    return 0;
}

#include<stdio.h>
#include<conio.h>

int ans=0,chk1=0,chk2=0,j,chk=0;

int main()
{
      int a[100],b[100];
      long long dec,i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);
      if(dec==1)chk=1;
	  dec-=1;

	  for(j=0;j<100;j++){
	  	a[j]=-1;
	  }

      while(dec>0)
      {
           a[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec)
	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(a[j]==0){
        	if(chk1==0){
        		ans+=i-j-1;
        		chk1=1;
        		continue;
        		//printf("cdC%dcCSCXZ",j);
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}

		  //printf("%d",a[j]);
      }
      if(chk1==0&&chk2==0){
      	ans+=i-1;

	  }
	  //printf("\n");
      for(j=i-2;j>0;j--){
      	ans+=j;

	  }

	  int net=0;
	  if(chk==0){
	  	net=ans;
	  }

	  chk=0;
	  //printf("%d",net);
      i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);
	   if(dec==1)chk=1;
	  for(j=0;j<100;j++){
	  	a[j]=-1;
	  }

      while(dec>0)
      {
           b[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec);

	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(b[j]==0){
        	if(chk1==0){
        		ans+=i-j-1;
        		chk1=1;
        		continue;
        		//printf("ewfdfsxx");
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}
		//printf("%d",a[j]);
      }
      if(chk1==0&&chk2==0){
      	ans+=i-1;

	  }
      for(j=i-2;j>0;j--){

		ans+=j;

	  }
	  //printf("%d",ans);
	  if(chk==0){
	  	ans-=net;
	  }else{
	  	ans=0;
	  }

      printf("%d",ans);

      //getch();
 }

#include<stdio.h>

int main()
{
	long long int input1,input2;
	int bin1[100]={0},bin2[100]={0};
	scanf("%lld%lld",&input1,&input2);
	int i=0,j=0;
	int count=0;
	int suc1=0;
	int suc2=0;

	while(input1)
	{
		bin1[i]=input1%2;
		if(bin1[i]==0)
			count++;
		input1/=2;
		i++;
	}

	if(count==1)
		suc1=1;

	count=0;
	while(input2)
	{
		bin2[j]=input2%2;
		if(bin2[j]==0)
			count++;
		input2/=2;
		j++;
	}

	if(count==1)
		suc2=1;

	int row1=0,row2=0;
	int len1=i,len2=j;

	i--;
	j--;
	while(bin1[i])
	{
		row1++;
		i--;
	}

	while(bin2[j])
	{
		row2++;
		j--;
	}

	int sum=0;
	if(len1!=len2)
	{
		int tmp1=len1-row1;
		int tmp2=row2-1;
		if(suc2)
			tmp2++;

		for(len1=len1+1;len1<len2;len1++)
			sum+=(len1-1);

		sum+=(tmp1+tmp2);
	}
	else
	{
		int tmp1=row1-1;
		int tmp2=row2-1;
		if(suc2)
			tmp2++;

		sum=tmp2-tmp1;
	}
	printf("%d\n",sum);
}

#include <stdio.h>

int main()
{
    int i, j, Ans = 0;
    unsigned long long a, b;
    scanf("%I64d %I64d", &a, &b);
    unsigned long long c = 1, d;
    for(i = 1; i < 64; ++i) {
        c <<= 1;
        c |= 1;
        for(j = 0; j < i; ++j) {
            d = c ^ (1ULL << j);
            if(d >= a && d <= b) {
                ++Ans;
            }
        }
    }
    printf("%d\n", Ans);
    return 0;
}

#include <stdio.h>
int main()
{
        int i,j,ca=0,cb=0,ans=0,k;
        long long int ta,tb,a,b,na,nb,p=2;
        scanf("%lld %lld",&a,&b);
        ta=a;tb=b;
        if(a>b)
        {
                int t;
                t=b;
                b=a;
                a=t;
        }
        for(i=1;i<100;i++)
        {
                a=a/p;
                ca++;
                if(a==0)
                {
                        break;
                }
        }
        for(i=1;i<100;i++)
        {
                b=b/p;
                cb++;
                if(b==0)
                {
                        break;
                }
        }
        /*      printf("ca %d cb %d\n",ca,cb);
                i=1;
                while(i<cb-1)
                {
                ab=ab+i;
                i++;
                }
                printf("%d\n",ab);
         */
        if(ca==cb)
        {
                for(i=0;i<ca-1;i++)
                {
                        p=1;na=0;
                        for(j=0;j<ca;j++)
                        {
                                if(j!=i)
                                        na=na+p;
                                p=p*2;
                        }
                        //                      printf("%d number %lld\n",i,na);
                        if(na>=ta && na<=tb)
                                ans++;
                        //                      printf("ans temp = %d\n",ans);
                }
        }
        else
        {
                for(k=ca;k<=cb;k++)
                {
//                      printf("entering loop k = %d\n",k);
                        for(i=0;i<k-1;i++)
                        {
//                              printf("entering loop i = %d\n",i);
                                p=1;na=0;
                                for(j=0;j<k;j++)
                                {
//                              printf("entering loop j = %d\n",j);
                                        if(j!=i)
                                                na=na+p;
                                        p=p*2;
                                }
//                              printf("%d number %lld\n",i,na);
                                if(na>=ta && na<=tb)
                                        ans++;
//                              printf("ans temp = %d\n",ans);
                        }
                }
        }
        printf("%d\n",ans);
        return 0;
}

//我服了这个问题了，我需要做得很精细！
#include<stdio.h>
unsigned long long binary_digit(unsigned long long n) {
	unsigned long long count=0;
	while(n>0) {
		n/=2;
		count++;
	}
	return count;
}
unsigned long long sum_to(unsigned long long a,unsigned long long b) {
	return (a+b)*(b-a+1)/2;
}
int main() {
	//读入起始年份和结束年份
	unsigned long long first_year,last_year;
	scanf("%lld%lld",&first_year,&last_year);
	/*
	printf("first year = %lld\n",first_year);
	printf("last year  = %lld\n",last_year);
	*/

	//获得起始年份和结束年份的二进制位数
	unsigned long long first_year_binary_digit=binary_digit(first_year);
	unsigned long long last_year_binary_digit=binary_digit(last_year);

	/*
	printf("\nfirst year binary digit = %d\n",first_year_binary_digit);
	printf("last year  binary digit = %d\n",last_year_binary_digit);
	*/

	//计算分两种情况
	//情况一first year 与 last year 的二进制位数相同！
	//情况二first year 与 last year 的二进制位数不相同！
	//变量不初始化，问题比较严重！
	unsigned long long possible;//没有初始化这个变量为什么会出现不同编译器的不同解答？
	unsigned long long base;
	unsigned long long one=1;//我所有的二进制操作都必须在64位上进行！
	//而且我所有的比较都必须是64位unsigned long long数据之间的比较
	//如果是long long之间的比较可能会出问题
	//就是我产生的可能是signed long long下的负数，负数之间比较就无法得到我想要的结果！
	unsigned long long result=0;
	unsigned long long i=0;
	if(first_year_binary_digit==last_year_binary_digit) {
		base=0;
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		unsigned long long count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year && possible<=last_year) count++;
			//printf("possible = %llx,%llu\n",possible,possible);
			/*
			printf("possible = %llx,%llu\n",first_year,first_year);
			printf("possible = %llx,%llu\n",last_year,last_year);
			*/
		}
		//printf("%d\n",count);
		result=count;

	} else {
		//分三个部分计算
		//第一部分与first year二进制位数相同的有多少个！
		//第二部分与last year二进制位数相同的有多少个！
		//第三部分在first year与last year之间的二进制位数有多少个！
		unsigned long long part1=0;
		base=0;//我忽略了这个条件！
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year) part1++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 1 = %d\n\n",count);

		unsigned long long part3=0;
		base=0;
		for(i=0;i<last_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<last_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible<=last_year) part3++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 3 = %d\n",count);

		unsigned long long part2;
		if(first_year_binary_digit+1==last_year_binary_digit) {
			part2=0;
		}else {
			part2=sum_to(first_year_binary_digit,last_year_binary_digit-2);
		}

		//printf("part 2 = %lld\n",part2);
		/*
		printf("%lld\n",part1+part2+part3);
		*/
		result=part1+part2+part3;
		//printf("result  = %lld\n",result);
	}
	printf("%lld\n",result);
	return 0;
}

//我服了这个问题了，我需要做得很精细！
#include<stdio.h>
unsigned long long binary_digit(unsigned long long n) {
	unsigned long long count=0;
	while(n>0) {
		n/=2;
		count++;
	}
	return count;
}
unsigned long long sum_to(unsigned long long a,unsigned long long b) {
	return (a+b)*(b-a+1)/2;
}
int main() {
	//读入起始年份和结束年份
	unsigned long long first_year,last_year;
	scanf("%lld%lld",&first_year,&last_year);
	/*
	printf("first year = %lld\n",first_year);
	printf("last year  = %lld\n",last_year);
	*/

	//获得起始年份和结束年份的二进制位数
	unsigned long long first_year_binary_digit=binary_digit(first_year);
	unsigned long long last_year_binary_digit=binary_digit(last_year);

	/*
	printf("\nfirst year binary digit = %d\n",first_year_binary_digit);
	printf("last year  binary digit = %d\n",last_year_binary_digit);
	*/

	//计算分两种情况
	//情况一first year 与 last year 的二进制位数相同！
	//情况二first year 与 last year 的二进制位数不相同！
	//变量不初始化，问题比较严重！
	unsigned long long possible=0;
	unsigned long long base=0;
	unsigned long long one=1;//我所有的二进制操作都必须在64位上进行！
	//而且我所有的比较都必须是64位unsigned long long数据之间的比较
	//如果是long long之间的比较可能会出问题
	//就是我产生的可能是signed long long下的负数，负数之间比较就无法得到我想要的结果！
	unsigned long long result=0;
	unsigned long long i=0;
	if(first_year_binary_digit==last_year_binary_digit) {
		base=0;
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		unsigned long long count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year && possible<=last_year) count++;
			//printf("possible = %llx,%llu\n",possible,possible);
			/*
			printf("possible = %llx,%llu\n",first_year,first_year);
			printf("possible = %llx,%llu\n",last_year,last_year);
			*/
		}
		//printf("%d\n",count);
		result=count;

	} else {
		//分三个部分计算
		//第一部分与first year二进制位数相同的有多少个！
		//第二部分与last year二进制位数相同的有多少个！
		//第三部分在first year与last year之间的二进制位数有多少个！
		unsigned long long part1=0;
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year) part1++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 1 = %d\n\n",count);

		unsigned long long part3=0;
		base=0;
		for(i=0;i<last_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<last_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible<=last_year) part3++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 3 = %d\n",count);

		unsigned long long part2;
		if(first_year_binary_digit+1==last_year_binary_digit) {
			part2=0;
		}else {
			part2=sum_to(first_year_binary_digit,last_year_binary_digit-2);
		}

		//printf("part 2 = %lld\n",part2);
		/*
		printf("%lld\n",part1+part2+part3);
		*/
		result=part1+part2+part3;
		//printf("result  = %lld\n",result);
	}
	printf("%lld\n",result);
	return 0;
}

#include<stdio.h>
typedef long long LL;

int main(void)
{
    LL a, b;
    int ans = 0, i, j;
    scanf("%I64d%I64d", &a, &b);
    for(i = 2; i < 63; i++)
        for(j = 0; j < i-1; j++)
        {
            LL tot = (1LL << i) - 1 - (1LL << j);
            if(a <= tot && tot <= b)
                ans++;
        }
    printf("%d", ans);
}

#include<stdio.h>
typedef long long LL;

int main(void)
{
    LL a, b;
    int ans = 0, i, j;
    scanf("%I64d%I64d", &a, &b);
    for(i = 2; i < 63; i++)
        for(j = 0; j < i-1; j++)
        {
            LL tot = ((1LL << i) - 1)^(1LL << j);
            if(a <= tot && tot <= b)
                ans++;
        }
    printf("%d", ans);
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007

int cmpfunc(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int min(int a,int b){
	return (a>b)?b:a;
}

int
main(int argc, char *argv[]) {
	long long a,b;
    scanf("%lld %lld",&a,&b);
    int sa[100],sb[100];
    int i=0;
    while(a>0){
        sa[i]=a%2;
        a/=2;
        i++;
    }
    int j=0;
    while(b>0){
        sb[j]=b%2;
        b/=2;
        j++;
    }
    int k;
    int len_a=i,len_b=j;
    long long ans=0;
    if(len_a==len_b) {
        for(i=len_a-1;i>=0;i--){
            if(sa[i]==sb[i] && sa[i]==1) ;
            else break;
        }
        if(i<0) {ans=0;}
        else{
            if(sa[i]==sb[i] && sa[i]==0){
                for(j=i-1;j>=0;j--){
                    if(sb[j]==0) {ans=0;break;}
                }
                if(j<0) {ans++;}
            } else{
                for(j=i-1;j>=0;j--){
                    if(sb[j]==0) break;
                }
                if(j>=0){
                    ans=i-j;
                    for(k=j-1;k>=0;k--){
                        if(sb[k]==0) break;
                    }
                    if(k<0) {ans++;}
                } else {ans=i+1;}
            }
        }
    } else {
        for(i=len_a-1;i>=0;i--){
            if(sa[i]==0) break;
        }
        if(i>=0){
            ans=i+1;
        }
        for(i=len_a+1;i<len_b;i++)
            {ans+=i-1;}
        //consider len_b only
        for(i=len_b-1;i>=0;i--){
            if(sb[i]==0) break;
        }
        if(i<0) {ans+=len_b-1;}
        else{
            ans+=len_b-2-i;
            for(k=i-1;k>=0;k--){
                if(sb[k]==0) break;
            }
            if(k<0) {ans++;}
        }
    }
    printf("%lld\n",ans);
	return 0;
}

#include <stdio.h>

int main() {
    long long a, b;
    scanf("%I64d%I64d", &a, &b);

    int c = 0, i, j;
    for(i = 0; (1LL << i) / 2 <= b; i++)
        for(j = 0; j <= i - 2; j++) {
            long long x = (1LL << i) - 1 - (1LL << j);
            c += (x >= a && x <= b);
        }

    printf("%d", c);

    return 0;
}

#include<stdio.h>
int main()
{
    unsigned long long int a;
    unsigned long long int b,s[100000],i,j,k,total;
    total = k = 0;
    s[k++] = 2;
    for(i=1;i< 64;i++)
    {
        j = i-1;
        while(j != 0)
        {
            s[k] = (s[k-1]>>1) + ((unsigned long long int)1 << i);
            j--;k++;
        }
        s[k] = (s[k-1] /2) + ((unsigned long long int)1 << (i+1));
        k++;
    }
    scanf("%llu %llu",&a, &b);
    for(i=0;s[i] <= b;i++)
    {
        if(s[i] >= a)
            total++;
    }

    printf("%lu\n",total);
    return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int cmpfunc(const void * a, const void * b)
{
    if (*(long long int*)a > *(long long int*)b )
        return 1;
    else if (*(long long int*)a == *(long long int*)b )
        return 0;
    else
        return -1;
}

long long int convert(int start, int pos) {
    return pow(2,start+1) - 1 - pow (2,pos);
}

int find(long long int * result, int count, long long int e, int * found) {
    int i;
    for (i=0;i<count;i++) {
        if (result[i] >= e )
            break;
    }
    if (result[i] == e)
        *found = 1;
    else
        *found = 0;
    return i;
}

int main(void) {
    // your code goes here
    long long int a, b;
    long long int result[2000];
    int indexA, indexB, count = 0, start, pos, i, foundA, foundB, res;

    for (start = 0; start <60; start++) {
        for (pos = 0; pos <=start-1; pos++) {
            result[count++] = convert(start, pos);
        }
    }

    qsort(result, count, sizeof(long long int), cmpfunc);
    /*
    for (i=0;i<20;i++) {
        printf("%lld ", result[i]);
    }
*/
    while(scanf("%lld %lld", &a, &b)!=-1) {
        indexA = find(result, count, a, &foundA);
        //printf("indexA = %d\n", indexA);
        indexB = find(result, count, b, &foundB);
        //printf("indexB = %d\n", indexB);

        if (foundB) {
            res = indexB - indexA + 1;
        } else {
            res = indexB - indexA;
        }

        printf("%d\n", res);
    }

    return 0;
}

#include<stdio.h>
long long int v[2000];
int main(){
    int l,i,r,j;
    long long int x,y;
    scanf("%I64d %I64d",&x,&y);
    for(i=l=0;i<60;i++){
        for(j=i-1;~j;j--){
            for(r=0;r<=i;r++){
                v[l]|=(long long int)(j!=r)<<(r);
            }
            l++;
        }
    }
    i=r=0;
    while(v[i]<x){
        i++;
    }
    while(v[i]<=y){
        i++;
        r++;
    }
    printf("%d",r);
    return 0;
}

#include<stdio.h>
long long int v[2000];
int main(){
    int l,i,r,j;
    long long int x,y;
    scanf("%I64d %I64d",&x,&y);
    for(i=l=0;i<=60;i++){
        for(j=i-1;~j;j--){
            for(r=0;r<=i;r++){
                v[l]|=(long long int)(j!=r)<<(r);
            }
            l++;
        }
    }
    i=r=0;
    while(v[i]<x){
        i++;
    }
    while(v[i]<=y){
        i++;
        r++;
    }
    printf("%d",r);
    return 0;
}

#include <stdio.h>
int main(void) {
    // your code goes here
    long long powtwo[59],k;
    powtwo[0]=1;
    int i,j,n1,n2,flag=1;
    for(i=1;i<=58;i++)powtwo[i]=powtwo[i-1]*2;
    long long arr[1770];
    arr[0]=2;j=0;
    for(i=1;i<=58;i++)
    {
    long long start=arr[j]+powtwo[i]+1;
    j++;
    arr[j]=start;
    for(k=i-1;k>=0;k--,j++)
    arr[j+1]=arr[j]+powtwo[k];
    }
    long long l,r;
    scanf("%lld %lld",&l,&r);
    for(i=0;i<1770;i++)
    {
    if(flag && arr[i]>=l){n1=i;flag=0;}
    if(arr[i]>r){n2=i;break;}
    }
    if(i==1770)n2=i;
    printf("%d\n",n2-n1);
    return 0;
}

#include <stdio.h>
#include <conio.h>

int main()
{
	long long int a,b;
	scanf("%I64d %I64d",&a,&b);
	int count=0;
	int i,j;
	for(i=0;i<=64;i++)
	{
		for(j=0;j<=i-2;j++)
		{
			long long int x=(1LL<<i)-1-(1LL<<j);
			if((x>=a)&&(x<=b))
			count++;
		}
	}
	printf("%d \n",count);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int l,n,m,k,i,j,count=0,count0=0;
	scanf("%lld%lld",&n,&m);
	i=n;
	for(i=0;i<=64;i++)
	{
		for(j=0;j<i-1;j++)
		{
			(count0)=pow(2,i)-pow(2,j)-1;
			if((count0)<=m&&(count0)>=n)
			{
				count++;
			}

		}

	}
	printf("%lld",count);
	return 0;
}

#include <stdio.h>
typedef long long ll;
int main()
{
 ll a,b;
 scanf("%lld%lld",&a,&b);
 ll i=0,j=0,count1=0,bit1=0,bit2=0,temp1=0,count2=0,temp2=0,ans=0;
    for(j=a;j>0;j=j/2)
    {
      if(j%2==1)
      temp1++;
      else
      temp1=0;
      bit1++;
     if(j%2==0)
     count1++;
    }

    for(j=b;j>0;j=j/2)
    {
     bit2++;
     if(j%2==1)
      temp2++;
      else
      temp2=0;
     if(j%2==0)
     count2++;
    }

    if(bit1==bit2)
    {
      ans += temp2-temp1;
      if(count2==1)
      ans++;
    }
    if(bit1!=bit2)
    {
    ans+=bit1-temp1;
    if(count2==1)
    ans++;
    ans+=temp2-1;
    }
    for(i=bit1+1;i<=bit2-1;i++)
    {
      ans += (i-1);
    }
  printf("%lld\n",ans);
  return 0;
}

#include <stdio.h>

typedef unsigned long long uint64;

int solve(uint64 a, uint64 b)
{
    int ans = 0;
    for (int i = 0; i < 64; i++) {
        for (int j = 0; j < i-1; j++) {
            uint64 cur = (1ULL << i) - 1 - (1ULL << j);
            if (cur >= a && cur <= b)
                ans++;
        }
        if ((1ULL << 1) / 2 > b) {
            return ans;
        }
    }
    return ans;
}

int main()
{
    uint64 a, b;
    scanf("%llu %llu", &a, &b);
    printf("%d\n", solve(a, b));
    return 0;
}

#include <stdio.h>
#include <math.h>
long long a[2000];
int main() {
	long long c,b;
	for (int i = 1;i<=60;i++) {
		for (int j = 1;j<i;j++) {
			a[(i-2)*(i-1)/2+j] = (long long)(pow(2,i)-pow(2,j-1)-1);
		}
	}
	while (scanf("%I64d %I64d",&c,&b)!=EOF) {
		int count=0;
		for (int i = 1;i<2000;i++) {
			if (a[i]>=c&&a[i]<=b) {
				count++;
			}
		}
		printf("%d\n",count);
	}
}

#include <stdio.h>
#include <math.h>

int main(){
    long long table[2000];
    int n = 0;
    for (int i = 2; i <= 60; i++){
        for (int j = 0; j < i - 1; j++){
            table[n] = (long long)(pow(2.0, i) - pow(2.0, j) - 1);
            n++;
        }
    }
    long long y1, y2;
    while (scanf("%I64d%I64d", &y1, &y2) != EOF){
        int count = 0;
        for (int i = 0; i < n;i++){
            if (table[i] <= y2 && table[i] >= y1) count++;
        }
        printf("%d\n", count);
    }
    return 0;
}

#include <stdio.h>

#define ull unsigned long long

ull getNum(long int amount) {
    ull result = 1;
    for (int i = 1; i < amount; ++i) {
        result = result << 1;
        result = result | 1;
    }
    return result;
}

long int getAmount(ull num) {
    long int amount = 1;
    while (num > 1) {
        ++amount;
        num = num / 2;
    }
    return amount;
}

int main() {
    ull left = 0;
    ull right = 0;
    scanf("%llu %llu", &left, &right);
    long int leftAm = getAmount(left);
    long int rightAm = getAmount(right);
    long int result = 0;
    for (long int i = leftAm; i <= rightAm ; ++i) {
        ull mask = getNum(i);
        for (long int j = 0; j < i - 1; ++j) {
            ull minus = (ull) 1 << j;
            ull tmp = mask - minus;
            if (tmp >= left && tmp <= right) ++result;
        }
    }
    printf("%ld", result);
    return 0;
}

/**Bismillahir Rahamnir Rahim.**/

#include <stdio.h>
int main()
{
    long long int a, b, c, i, lnth_a, lnth_b, ans,tmp, indx1, indx2, cnt=0,k, cndtn=1;
    char aa[30000], bb[30000];
    scanf("%I64d%I64d", &a, &b);
    for(i=0; a!=0; i++)
    {
        c = a%2;
        aa[i] = c+48;
        a/=2;
    }
    aa[i] = '\0';
    for(i=0; b!=0; i++)
    {
        c = b%2;
        bb[i] = c+48;
        b/=2;
    }
    bb[i] = '\0';
    lnth_a = strlen(aa);
    lnth_b = strlen(bb);
    for(i=0, k=lnth_a-1; i<lnth_a/2; i++, k--)
    {
        tmp = aa[i];
        aa[i] = aa[k];
        aa[k] = tmp;
    }
    for(i=0, k=lnth_b-1; i<lnth_b/2; i++, k--)
    {
        tmp = bb[i];
        bb[i] = bb[k];
        bb[k] = tmp;
    }
    for(i=0, indx1=0; aa[i]; i++)
    {
        if(aa[i] == '0')
        {
            indx1 = lnth_a-i;
            break;
        }
    }
    for(i=0, indx2=lnth_b-1, cndtn=1; bb[i]; i++)
    {
        if(bb[i] == '0')
        {
            if(cndtn==1)
            {
                indx2 = i-1;
                cndtn = 0;
            }
            cnt++;
        }

    }
    if(cnt==1) indx2++;
    if(lnth_a==lnth_b)
    {
        tmp = lnth_a-1;
        ans = (indx1+indx2)-tmp;
        printf("%I64d\n", ans);
    }
    else
    {
        tmp = lnth_b - lnth_a;
        if(tmp == 1) printf("%I64d\n", indx1+indx2);
        else
        {
            for(i = lnth_a+1, ans=0; i<lnth_b; i++)   ans+= (i-1);
            ans += (indx1+indx2);
            printf("%I64d\n", ans);
        }
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define clr(ar) memset(ar, 0, sizeof(ar))

int n;
long long dp[75][75][2][2];
char str[75], temp[75], visited[75][75][2][2];

long long F(int i, int c, int flag, int nz){
    if (i == n) return (c == 1);
    if (visited[i][c][flag][nz]) return dp[i][c][flag][nz];

    long long res = 0;
    if (flag){
        res += F(i + 1, c, 1, 1);
        if (nz) res += F(i + 1, c + 1, 1, nz);
        else res += F(i + 1, c, 1, nz);
    }
    else{
        if (str[i] == 48) res += F(i + 1, c + 1, 0, nz);
        else{
            res += F(i + 1, c, 0, 1);
            if (nz) res += F(i + 1, c + 1, 1, nz);
            else res += F(i + 1, c, 1, nz);
        }
    }

    visited[i][c][flag][nz] = 1;
    return (dp[i][c][flag][nz] = res);
}

long long S(long long x){
    if (!x) return 0;
    int i, d = 0;
    while (x) {
        temp[d++] = (x & 1) + 48;
        x >>= 1;
    }

    for (n = 0, i = d - 1; i >= 0; i--) str[n++] = temp[i];
    str[n] = 0;
    clr(visited);
    return F(0, 0, 0, 0);
}

int main(){
    long long a, b;
    scanf("%lld %lld", &a, &b);
    printf("%lld\n", S(b) - S(--a));
    return 0;
}

#include<stdio.h>

int max(int a , int b){return a>b?a:b;}
int min(int a , int b){return a<b?a:b;}
int binsear(long long);

long long ar[10004];
int len;

int main(){
	len=0;
	int i,j,k;
	long long x=1,i1,i2;
	for(i=2;i<65;i++){
		x=x<<1;
		x++;
		for(j=i-2;j>=0;j--){
			ar[len++]=x^((long long)1<<j);
			//	printf("adding %I64d\n",ar[len-1]);
		}
	}
	scanf("%I64d %I64d",&i1,&i2);
	printf("%d\n",binsear(i2)-binsear(i1-1));
	return 0;
}

int binsear(long long x){
	int s,e,m;
	s=0;e=len-1;
	if(x<ar[s])return 0;
	while(s<e){
		m=(s+e+2)>>1;
		if(ar[m]<=x)
			s=m;
		else
			e=m-1;
	}
	//	printf("binsear %I64d=%d\n",x,s);
	return s+1;
}

#include <stdio.h>
#include <stdlib.h>

typedef unsigned long long int llu;

void printBits(size_t const size, void const * const ptr)
{
    unsigned char *b = (unsigned char*) ptr;
    unsigned char byte;
    int i, j;

    for (i=size-1;i>=0;i--)
    {
        for (j=7;j>=0;j--)
        {
            byte = b[i] & (1<<j);
            byte >>= j;
            printf("%u", byte);
        }
    }
    puts("");
}

int numberOfZeros(llu num, size_t const size){
	int i, result, temp;
	for(i = 0, result = 0, temp = 0; i < size*8; i++){
		if(num%2 == 0){
			temp++;
		} else {
			result += temp;
			temp = 0;
		}
		num = num >> 1;
	}

	return result;
}

int findMax(llu* b){
	int i;
	llu max = 1, mask = 3;
	max = ~(max << (sizeof(max)*8 - 2));

	for(i = 0; i < sizeof(max)*8; i++){
		if(max <= *b){
			break;
		}
		max = max >> 1;
	}

	mask = mask << (61 - i);
	for(; (max ^ mask) <= *b && i < 62; max = max ^ mask, mask = mask >> 1, i++);

	*b = max;

	return 62 - i;
}

int findMin(llu *a){
	int i;
	llu min = ~0, mask = 3;

	for(i = 0; i < sizeof(min)*8; i++){
		if((min >> 1) <= *a){
			break;
		}
		min = min >> 1;
	}

	min = min ^ 1;
	i = 0;
	// printBits(sizeof(min), &min);
	for(; (min ^ mask) > *a; min = min ^ mask, mask = mask << 1, i++);

	if((min ^ mask) == *a){
		min = min ^ mask;
		i++;
		if(numberOfZeros(min, sizeof(min)) != 1){
			min = min ^ mask;
			i--;
		}
	}

	*a  = min;

	return i;
}

int len(llu a){
	int temp, i, result;

	for(i = 0, temp = 0, result = 0; i < 8*sizeof(a); i++, temp++, a = a >> 1){
		if(a%2 != 0){
			result += temp;
			temp = 0;
		}
	}

	return ++result;
}

int main(){
	llu i, a, b, ta, tb, result = 0;
	int pa, pb;

	scanf("%llu %llu", &a, &b);
	ta = a;
	tb = b;

	pb = findMax(&tb);
	// printf("Max: %lld\n", tb);
	pa = findMin(&ta);
	// printf("Min: %lld, pa: %d\n", ta, pa);
	// printBits(sizeof(ta), &ta);

	if(ta >= a && tb <= b && ta <= tb && pa >= 0 && pb >= 0){
		for(i = len(ta); i <= len(tb); i++){
			result += i - 1;
		}

		result -= pb;
		result -= len(ta) - 2 - pa;
	}

	printf("%llu", result);
	return 0;
}
// 1453789088359

#include<stdio.h>

long long int a;
long long int b;
int lena, lenb;
long long int twos[70];
long long int nums[10000];
long long int ind = 0;

void two(){
    twos[0] = 1;
    int i;
    for(i = 1; i < 70; i++) twos[i] = 2 * twos[i - 1];
    return;
}

int find_len(long long int x){
    int i;
    for(i = 0; i < 100; i++){
        if(twos[i] > x) return i - 1;
    }
}

void make_nums(){
    int i, j;
    for(i = lena; i <= lenb + 1; i++){
        for(j = i - 2; j > -1; j--){
            nums[ind] = twos[i] - twos[j] - 1;
            ind++;
        }
    }
    return;
}

main(){
    scanf("%I64d %I64d", &a, &b);
    two();
    lena = find_len(a);
    lenb = find_len(b);
    make_nums();
    long long int start, end;
    int i;
    for(i = 0; i < ind; i++){
        if(nums[i] > a - 1) break;
    }
    start = i;
    for(i = ind - 1; i > -1; i--){
        if(nums[i] < b + 1) break;
    }
    end = i;
    printf("%I64d", end - start + 1);
    return 0;
}

#include<stdio.h>
typedef long long int ll;
int main()
{
	ll i,j,a,b,c;
	scanf("%I64d%I64d",&a,&b);
	ll cnt=0;
	for(i=0;1LL<<i<=2*b;i++)
	{
	//	printf("%Ld\n",i);
		ll res;
		ll tmp=1LL<<i;
		tmp--;
		for(j=0;j<=i-2;j++)
		{
			//printf("%Ld\t%Ld\t%Ld\n",i,1LL<<i,1LL<<j);
			res=tmp-(1LL<<j);
			//printf("%Ld\t%Ld\n",i,res);
			if(res>=a&&res<=b)
			{
				cnt++;
			}
		}
	}
	printf("%I64d\n",cnt);
}

/* Problem: 611B - New Year and Old Property */
/* Solver: Gusztav Szmolik */

#include <stdio.h>

int main ()
    {
    unsigned long long a;
    unsigned long long b;
    unsigned long long n;
    unsigned long long d;
    unsigned short c;
    unsigned long long dt;

    if (scanf("%I64u %I64u",&a,&b) != 2)
        return -1;
    if (a < 1 || a > 1000000000000000000ULL || b < 1 || b > 1000000000000000000ULL)
        return -1;
    if (a > b)
        return -1;
    n = 2;
    d = 1;
    while (n < a)
        {
        n = 2*n+2;
        d *= 2;
        }
    n = n+1-d;
    c = 0;
    dt = d;
    while (n <= b)
        {
        if (n >= a)
            c++;
        if (dt > 1)
            {
            n += dt;
            dt /= 2;
            n -= dt;
            }
        else
            {
            d *= 2;
            n = 2*n+3-d;
            dt = d;
            }
        }
    printf ("%hu\n",c);
    return 0;
    }

#include<stdio.h>
#include<math.h>
int main()
{
	long long int ac,b,temp,i,j,k,a[3005];
	int count;
	k = 0;
	count = 0;
	for(i=1;i<=60;i++)
	{
		temp = (long long)pow(2,i) - 1;
		for(j=0;j<i-1;j++)
		{
			a[k] = temp - (long long)pow(2,j);
			//printf("%lld\n",a[k]);
			k++;
		}
	}
	/*for(i=0;i<1770;i++)
	{
		printf("%lld\n",a[i]);
	}*/
	scanf("%lld %lld",&ac,&b);
	for(j=0;j<1771;j++)
	{
		if(a[j]>=ac && a[j]<=b)
		{
			//printf("%lld\n",a[j]);
			count = count + 1;
		}
	}
	printf("%d\n",count);
return 0;
}

#include<stdio.h>

long long int ans=0,a,b;
int f(long long int x, long long int cnt)
{
	if(x>b)
		return;

	if(a<=x && x<=b && cnt ==1)
		ans++;

	if(cnt == 0)
		f(2*x,cnt+1);

	f(2*x+1,cnt);
}

int main()
{
	scanf("%lld %lld",&a,&b);
	f(1,0);
	printf("%lld",ans);
	return 0;
}

#include<stdio.h>
int main(){
	long long int j,ma = 1,na = 1,k,car = 1,i,sayi,a,b,n = 0,m = 0,sonuc,ensonuc = 0;
	scanf("%lld %lld",&a,&b);
	sayi = a;
	while(sayi>=1){
		sayi=sayi/2;
		na*=2;
		n++;
	}
	na--;
	sayi = b;
	while(sayi>=1){
		sayi=sayi/2;
		ma*=2;
		m++;
	}
	ma--;
	//sayi;ar
	for(i = n ; i <= m ; i++){
		car = 1;
		for(k = 1 ; k <= i ; k++)
			car*=2;
		sayi = car - 1;
		for(j = 0 ; j < i-1 ; j++){
			car = 1;
			for(k = 1 ; k <= j ; k++)
				car*=2;
			if(sayi-car>=a&&sayi-car<=b)
				ensonuc++;
		}
	}
	printf("%lld",ensonuc);
	return 0;
}

#include <stdio.h>
#include <math.h>

#define Max 10000
long long mpow(int a, int b) {
    long long res = 1;
    int i;
    for ( i = 0; i < b; i++) res *= a;
    return res;
}
int main()
{
    long long num[Max], tmp = 1, cur = 0, k = 0, cont, a, b;
    int i, j, l;

    for (i = 2; i <= 64; i++)
    {
        tmp = tmp << 1;
        tmp = tmp | 1;
        //printf("tmp = %I64d\n", tmp);
        for (j = 0; j < i-1; j++)
        {
            cur = tmp-mpow(2,j);
            num[k++] = cur;
//            //printf("%I64d\n", cur);
//            for (l = 1; l <= 64; l++)
//            {
//                printf("%I64d", cur&1);
//                cur = cur >> 1;
//            }
//            printf("\n");
//            //system("pause");
        }
    }

    num[k] = tmp-mpow(2,63);
    cur = num[k];
    while (scanf("%I64d%I64d", &a, &b) != EOF)
    {
        cont = 0;
        for (i = 0; i <= k; i++)
        {
            if (num[i] >= a && num[i] <= b)
            {
                cont++;
            }
        }
        printf("%I64d\n", cont);
    }
    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
	unsigned long long int s, e, cnt2=0, cnt1=0, temp2, i, base,base1, temp;
	scanf("%llu %llu",&s, &e);
	for(base1=2, temp2=2;base1<=e;base1=base1<<1|1){
		for(base=base1,temp=temp2;base<=e;base=base|temp){
			if(base>=s&&base<=e) cnt2++;
			temp<<=1;
		}
		temp2<<=1;
	}
	/*printf("%llu\n",cnt2);
	for(base1=2;base1<s;base1=base1<<1|1){
		for(base=1,temp=2;base<s;base=base|temp){
			if(base>=s&&base<=e) cnt1++;
			temp=temp<<1;
		}
	}
	printf("%llu\n\n\n",cnt1);*/
	printf("%llu\n",cnt2);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef __linux__
#define LLD     "%lld"
#else
#define LLD     "%I64d"
#endif

typedef long long ll;

int
cd (ll a)
{
	int d = 0;

	while (a) {
		a /= 2;
		++d;
	}
	return d;
}

int
main()
{
	ll	a, b;
	int	ans = 0;
	int	i;
	ll	fn, ln;
	ll	t, fd, ld;

	scanf (LLD LLD, &a, &b);

	fd = cd (a);
	ld = cd (b);
	for (i = fd+1; i <= ld-1; i++) {
		ans += (i-1);
	}

	fn = (1ll << fd) - 1;
	ln = (1ll << ld) - 1;

	if (fd >= 2) {
		t = 1ll  << (fd -2);
	} else {
		t = 0;
	}

	while (t) {
		ll  d;

		d = fn ^ t;
		t >>= 1;

		if (d >= a && d <= b) {
			++ans;
		}
	}
	if (ld != fd) {
		t = 0;
		if (ld >= 2) {
			t = 1ll << (ld -2);
		}

		while (t) {
			ll  d;

			d = ln ^ t;
			t >>= 1;

			if (d >= a && d <= b) {
				++ans;
			}
		}
	}
	printf ("%d\n", ans);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
long long int power(long long int x,long long int y)
{
	if(y==0)
		return 1;
	else if(y%2==0)
		return power(x,y/2)*power(x,y/2);
	else
		return x*power(x,y/2)*power(x,y/2);
}
int cmpfunc (const void * a, const void * b)
{
	return ( *(int*)a - *(int*)b );
}
int main()
{
	long long int n,i,j,a[2484],l=0,count=0,b,c;
	scanf("%lld %lld",&b,&c);
	for(i=2;i<=70;i++)
	{
		for(j=i-2;j>=0;j--)
		{
			a[l]=power(2,i)-1-power(2,j);
			l++;
		}
	}
//	printf("%lld\n",l);
	qsort(a, 2415, sizeof(long long int), cmpfunc);
	for(i=0;i<2415;i++)
	{
		if(b<=a[i] && a[i]<=c && a[i]!=a[i+1])
		{
			count++;
		}
	}
	printf("%lld\n",count);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	long long int a,b;
	scanf("%lld%lld", &a,&b);

	int n,m,i,j;

	for(i=0;;i++)
	{
		if((pow(2,i))>a)
		{
			n=i;
			break;
		}
	}

	for(i=0;;i++)
	{
		if((pow(2,i))>b)
		{
			m=i;
			break;
		}
	}

	long long int count=0;

	for(i=n;i<=m;i++)
	{
		for(j=0;j<i-1;j++)
		{
			long long int k=pow(2,i)-1;
			long long int l=pow(2,j);

			if((k-l)>=a && (k-l)<=b)
			{
				count++;
			}
		}
	}

	printf("%lld", count);

	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
	long long unsigned int a,b,k=0,d;
	scanf("%I64u%I64u",&a,&b);
	int i , j ;
	for(i=0;i<=62;i++)
		for( j=0;j<i-1;j++)
		{
			d=pow(2,i)-1-pow(2,j);
			if(a<=d && d<=b)
				k++;
		}
	printf("%I64u",k);
	return 0;
}

#include <stdio.h>

int main(){
    int i,j,count=0;
    long long unsigned mask=(~0),a,b,num,n=1;
    scanf("%I64d %I64d",&a,&b);

    for(i=0;i<64;i++){
        for(j=0;j<64-i-1;j++){
            num=((mask>>i)^(n<<j));

            if(num>=a && num<=b)count++;
        }

    }
    printf("%d",count);
    return 0;

}

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define MAX 200010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int n;
char str[100], temp[100];
bool visited[100][100][2][2];
long long dp[100][100][2][2];

long long F(int i, int c, int flag, int nz){
    if (i == n) return (c == 1);
    if (visited[i][c][flag][nz]) return dp[i][c][flag][nz];

    long long res = 0;
    if (flag){
        if (nz) res += F(i + 1, c + 1, 1, nz);
        else res += F(i + 1, c, 1, nz);
        res += F(i + 1, c, 1, 1);
    }
    else{
        if (str[i] == 48) res += F(i + 1, c + 1, 0, nz);
        else{
            if (nz) res += F(i + 1, c + 1, 1, nz);
            else res += F(i + 1, c, 1, nz);
            res += F(i + 1, c, 0, 1);
        }
    }

    visited[i][c][flag][nz] = true;
    return (dp[i][c][flag][nz] = res);
}

long long S(long long x){
    if (!x) return 0;
    int i, j, k, d = 0;
    for (; ;){
        temp[d++] = (x & 1) + 48;
        x >>= 1;
        if (!x) break;
    }

    for (n = 0, i = d - 1; i >= 0; i--) str[n++] = temp[i];
    str[n] = 0;

    clr(visited);
    return F(0, 0, 0, 0);
}

int main(){
    long long a, b, res;

    while (scanf("%I64d %I64d", &a, &b) != EOF){
        res = S(b) - S(--a);
        printf("%I64d\n", res);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int count(long long a);
    long long creat(int n);
    long long a,b,x,n,xn;
    int num1,num2,i,res;
    scanf("%lld%lld",&a,&b);
    //printf("%lld %lld",a,b);
    res=0;
    //a=1;
    //a<<=1;
    num1=count(a);
    //printf("%lld %d\n",a,num1);
    num2=count(b);
    x=creat(num1);
    n=1;
    for(i=0;i<num1;i++)
    {
        xn=x^n;
        if(xn>=a && xn<=b)res++;
        n<<=1;
    }
    if(num2>num1)
    {
        n=1;
        for(i=num1;i<num2-1;i++)
        {
            res+=i;
        }
        x=creat(num2);
        for(i=0;i<num2-1;i++)
        {
            xn=x^n;
            if(xn<=b && xn>=a)res++;
            n<<=1;
        }
    }
    printf("%d\n",res);
    return 0;
}
int count(long long a)
{
    int i=0;
    while(a>0)
    {
        i++;
        a>>=1;
    }
    return i;
}
long long creat(int n)
{
    long long x=1;
    int i;
    for(i=0;i<n-1;i++)
    {
        x<<=1;
        x++;
    }
    return n==0?0:x;
}

#include<stdio.h>
int asd(__int64 l,__int64 r);
int main()
{
	__int64 i,j,k,m,n,l=0,r=0,sum,ans=0,temp;
	scanf("%I64d%I64d",&n,&m);
	for(k=1;k<=n;k*=2)
	l++;
	for(k=1;k<=m;k*=2)
	r++;
	l--;
	for(i=1;i<r;i++)
	{
		temp=0;
		sum=0;
		k=1;
		while(sum<=m)
		{
			if(sum>=n&&sum<=m)
			ans++;
			temp++;
			if(temp!=i)
			sum+=k;
			k*=2;
		}
	}
	printf("%I64d",ans);
	return 0;
}

#include<stdio.h>
int asd(__int64 l,__int64 r);
int main()
{
    __int64 i,j,k,m,n,l=0,r=0,sum,ans=0,temp;
    scanf("%I64d%I64d",&n,&m);
    for(k=1;k<n;k*=2)
    l++;
    for(k=1;k<m;k*=2)
    r++;
    l--;
    for(i=1;i<r;i++)
    {
        temp=0;
        sum=0;
        k=1;
        while(sum<=m)
        {
            if(sum>=n&&sum<=m)
            ans++;
            temp++;
            if(temp!=i)
            sum+=k;
            k*=2;
        }
    }
    printf("%I64d",ans);
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	long long int a, b;
	int count = 0;
	scanf("%I64d%I64d", &a, &b);
	while (a <= b)
	{
		if (1 ==__builtin_ctzll(a++))
		{
			count++;
		}
	}
	printf("%d", count);
}

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>

int main()
{
	long long lInput1;
	long long lInput2;

	int iCnt;
	long long lTotalCnt = 0;
	long long lCheck;

	long long i;

	scanf("%lld%lld",&lInput1,&lInput2);

	for( i = lInput1 ; i < lInput2 ; i++ )
	{

		lCheck = i;
		iCnt = 0;
		while( lCheck )
		{
			if ( (lCheck & 0x1) == 0 )
				iCnt++;
			lCheck >>= 1;
		}
		if( iCnt == 1 )
			lTotalCnt++;

	}

	printf("%lld\n",lTotalCnt);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>

unsigned long long FindMax(unsigned  long long lData )
{
	unsigned long long lRet = 0x1;

	while( lRet < lData )
	{
		lRet <<= 1;
	}

	return lRet - 1;
}

int main()
{

	unsigned long long lInput1;
	unsigned long long lInput2;

	unsigned long long lTotalCnt = 0;
	unsigned long long lCheck;
	unsigned long long lMax ;

	unsigned long long i = 0x1;
	unsigned long long ii = 0x0;
	int iCnt = 0;

	scanf("%lld%lld",&lInput1,&lInput2);

	while( i < lInput2 )
	{
		i <<= 1;
		iCnt++;
	}

	lMax = i - 1;

	i = 0x1;

	iCnt;
	ii = iCnt;

	while( lCheck >= lInput1 )
	{
		lCheck = lMax - i ;
		if( lCheck >= lInput1 && lCheck <= lInput2 )
		{
			lTotalCnt++;
		}
		else if( lCheck < lInput1 )
			break;

		i <<= 1;
		ii--;

		if( ii == 1 )
		{
			i = 0x1;
			lMax >>= 1;
			ii = iCnt-1;
			iCnt--;
		}
	}

	printf("%lld\n",lTotalCnt);

}

#include<stdio.h>
#include<math.h>

int main()
{
    long long int a,b,i,j,num,t,c=0;
    scanf("%I64d %I64d",&a,&b);
    for(i=62;i>=2;i--)
    {
        num=pow(2,i)-1;
        if(num==3)
        {
            t=2;
            if(t>=a&&t<=b)
                c++;
        }
        else
            {
            for(j=i-2;j>=0;j--)
            {
                t=num-pow(2,j);
                if(t>=a&&t<=b&&t!=1)
                    c++;

            }
            }
    }

    printf("%I64d\n",c);

    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    long long int a,b,i,j,num,t,c=0;
    scanf("%I64d %I64d",&a,&b);
    for(i=61;i>=2;i--)
    {
        num=pow(2,i)-1;

            for(j=i-1;j>=1;j--)
            {
                t=num-pow(2,j);
                if(t>=a&&t<=b)
                    c++;
            }

    }
    if(a==1)
    c-=1;
    printf("%I64d\n",c);

    return 0;
}

#include<stdio.h>
#include<math.h>

int main()
{
    long long int a,b,i,j,num,t,c=0;
    scanf("%I64d %I64d",&a,&b);
    for(i=61;i>=2;i--)
    {
        num=pow(2,i)-1;

            for(j=i-1;j>=1;j--)
            {
                t=num-pow(2,j);
                if(t>=a&&t<=b)
                    c++;
            }

    }

    printf("%I64d\n",c);

    return 0;
}

#include <stdio.h>

int main() {
	int i, j, cnt;
	long long a, b, c, d;

	scanf("%lld%lld", &a, &b);
	cnt = 0;
	for (i = 0; (long long) i < 60; i++) {
		c = ((long long) 1 << i) - 1;
		for (j = 0; j < i - 1; j++) {
			d = c - ((long long) 1 << j);
			if (d >= a && d <= b)
				cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

#include <stdio.h>

int main() {
	long long a, b, c;
	int i;

	scanf("%lld%lld", &a, &b);
	c = b - a;
	for (i = 0; (long long) 1 << (i + 1) < b - a; i++)
	   ;
	printf("%d\n", i);
	return 0;
}

#include<stdio.h>
#include<conio.h>

int ans=0,chk1=0,chk2=0,j;

int main()
{
      int a[100];
      long long dec,i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);
	  dec-=1;

	  for(j=0;j<100;j++){
	  	a[j]=-1;
	  }

      while(dec>0)
      {
           a[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec)
	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(a[j]==0){
        	if(chk1==0){
        		ans+=i-j;
        		chk1=1;
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}

		  //printf("%d",a[j]);
      }
      for(j=i-1;j>0;j--){
      	ans+=j-1;

	  }

	  int net=ans;
	  //printf("%d",net);
       dec,i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);

	  for(j=0;j<100;j++){
	  	a[j]=-1;
	  }

      while(dec>0)
      {
           a[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec);

	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(a[j]==0){
        	if(chk1==0){
        		ans+=i-j;
        		chk1=1;
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}

		  //printf("%d",a[j]);
      }
      for(j=i-1;j>0;j--){
      	ans+=j-1;

	  }
	  ans-=net;
      printf("%d",ans);

      //getch();
 }

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
long long int funk(long long int x,long long int b){
long long int m=1;

long long int a;

for(a=1;a<=b;a++){
m=m*x;
}
return m;

}
main(){

    long long int a,b,c;
  long long  int increase;
   long long int unos,unos1;
    scanf("%lld%lld",&unos,&unos1);
  long long  int x;
   long long int counter=0;

    for(a=64;a>=1;a--){
            x=funk(2,a)-1;
            increase=1;
            for(b=1;b<=a;b++)
            {
                increase=increase*2;
               printf("%lld\n",x-increase);
                    if( ((x-increase)>=unos) && ((x-increase) <=unos1) ){
                           counter++;
                    }

            }

    }

    printf("%lld",counter);

}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
long long int funk(long long int x,long long int b){
long long int m=1;

long long int a;

for(a=1;a<=b;a++){
m=m*x;
}
return m;

}
main(){

    long long int a,b,c;
  long long  int increase;
   long long int unos,unos1;
    scanf("%lld%lld",&unos,&unos1);
  long long  int x;
   long long int counter=0;

    for(a=64;a>=1;a--){
            x=funk(2,a)-1;
            increase=1;
            for(b=1;b<=a;b++)
            {
                increase=increase*2;
              // printf("%lld\n",x-increase);
                    if( ((x-increase)>=unos) && ((x-increase) <=unos1) ){
                           counter++;
                    }

            }

    }

    printf("%lld",counter);

}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
long long int funk(long long int x,long long int b){
long long int m=1;

long long int a;

for(a=1;a<=b;a++){
m=m*x;
}
return m;

}
main(){

    long long int a,b,c;
  long long  int increase;
   long long int unos,unos1;
    scanf("%lld%lld",&unos,&unos1);
  long long  int x;
   long long int counter=0;

    for(a=64;a>=3;a--){
            x=funk(2,a)-1;
            increase=1;
            for(b=1;b<=a;b++)
            {
                increase=increase*2;
               //printf("%lld\n",x-increase);
                    if( ((x-increase)>=unos) && ((x-increase) <=unos1) ){
                           counter++;
                    }

            }

    }

    printf("%lld",counter);

}

#include<stdio.h>
#include<math.h>
int main(){

    int n , i, num = 0,shift,sh = 1;
    long long x,y,test1 = 2,test2,z=2;
    scanf("%lld %lld",&x,&y);
    long long base = (long long)(ceil(log2l(y)));
    while(sh < base){
        test2 = test1;
        z = (long long)pow(2,sh);
        while(test2 <= y){
            if(test2 >= x && test2 <= y)  num++;
            z *= 2;
            test2 += z;
        }
        sh++;
        test1 = (test1<<1)+1;
    }
    printf("%d\n",num);
return 0;
}

#include <stdio.h>

int main()
{
	long long a, b, x = 0, y = 0, k = -1, cnt = 0;

	freopen("input.txt", "r", stdin);

	scanf("%I64d %I64d", &a, &b);

	while (y < a) {
		cnt++;
		y = y | ((long long)1 << x);
		x--;

		if (x == -1) {
			x = ++k;
			y = (y | ((long long)1 << (x + 1))) & ~((long long)1 << x);
		} else {
			y = y & ~((long long)1 << x);
		}
	}

	cnt = 0;

	while (y <= b) {
		cnt++;
		y = y | ((long long)1 << x);
		x--;

		if (x == -1) {
			x = ++k;
			y = (y | ((long long)1 << (x + 1))) & ~((long long)1 << x);
		}
		else {
			y = y & ~((long long)1 << x);
		}
	}

	printf("%I64d", cnt);

	return 0;
}

#include<stdio.h>

long long g(int a[64],int l)
{
    long long ans;
    int i;

    ans=0;
    for(i=0;i<l;i++)
    {
        ans*=2;
        ans+=a[i];
    }

    return ans;
}

int f(long long x)
{
    int ans,i,j,l,a[64];
    long long temp;

    if(x<2)return 0;
    temp=x;
    l=0;
    while(temp)
    {
        l++;
        temp/=2;
    }
    ans=0;
    for(i=0;i<l-1;i++)
    {
        for(j=0;j<64;j++)a[j]=0;
        a[i]=0;
        for(j=i-1;j>=0;j--)a[j]=1;
        for(j=i+1;j<l;j++)
        {
            a[j]=1;
            temp=g(a,j+1);
            if(temp<=x)ans++;
        }
    }

    return ans;
}

int main()
{
    long long a,b;

    scanf("%I64d%I64d",&a,&b);
    printf("%d\n",f(b)-f(a-1));

    return 0;
}

#include<stdio.h>
#include<conio.h>

int ans=0,chk1=0,chk2=0,j;

int main()
{
      int a[100],b[100];
      long long dec,i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);
	  dec-=1;

	  for(j=0;j<100;j++){
	  	a[j]=-1;
	  }

      while(dec>0)
      {
           a[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec)
	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(a[j]==0){
        	if(chk1==0){
        		ans+=i-j-1;
        		chk1=1;
        		continue;
        		//printf("cdC%dcCSCXZ",j);
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}

		  //printf("%d",a[j]);
      }
      if(chk1==0&&chk2==0){
      	ans+=i-1;

	  }
	  //printf("\n");
      for(j=i-2;j>0;j--){
      	ans+=j;

	  }

	  int net=ans;
	  //printf("%d",net);
      i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);

	  for(j=0;j<100;j++){
	  	a[j]=-1;
	  }

      while(dec>0)
      {
           b[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec);

	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(b[j]==0){
        	if(chk1==0){
        		ans+=i-j-1;
        		chk1=1;
        		continue;
        		//printf("ewfdfsxx");
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}
		//printf("%d",a[j]);
      }
      if(chk1==0&&chk2==0){
      	ans+=i-1;

	  }
      for(j=i-2;j>0;j--){

		ans+=j;

	  }
	  //printf("%d",ans);
	  ans-=net;
      printf("%d",ans);

      //getch();
 }

#include<stdio.h>
#include<conio.h>

int ans=0,chk1=0,chk2=0,j;

int main()
{
      int a[20];
      long long dec,i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);
      while(dec>0)
      {
           a[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec)
	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(a[j]==0){
        	if(chk1==0){
        		ans+=i-j;
        		chk1=1;
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}

		  //printf("%d",a[j]);
      }
      for(j=i-1;j>0;j--){
      	ans+=j-1;

	  }

	  int net=ans;
	  //printf("%d",net);
       dec,i=0;
      //printf("Enter the decimal number to find its binary number\n");
      scanf("%I64d",&dec);
	  dec-=1;
      while(dec>0)
      {
           a[i]=dec%2;
           i++;
           dec=dec/2;
      }
      //printf("Binary number of %d is = ",dec);

	ans=0;chk1=0;chk2=0;
      for(j=i-1;j>=0;j--)
      {
        if(a[j]==0){
        	if(chk1==0){
        		ans+=i-j;
        		chk1=1;
			}
			else if(chk2==0&&chk1==1){
				chk2=1;
				ans-=1;

			}

		}

		  //printf("%d",a[j]);
      }
      for(j=i-1;j>0;j--){
      	ans+=j-1;

	  }
	  net-=ans;
      printf("%d",net);

      //getch();
 }

#include<stdio.h>

int main()
{
	long long int input1,input2;
	int bin1[100],bin2[100];
	scanf("%lld%lld",&input1,&input2);
	int i=0,j=0;
	int count=0;
	int suc1=0;
	int suc2=0;

	while(input1)
	{
		bin1[i]=input1%2;
		if(bin1[i]==0)
			count++;
		input1/=2;
		i++;
	}

	if(count==1)
		suc1=1;

	count=0;
	while(input2)
	{
		bin2[j]=input2%2;
		if(bin2[j]==0)
			count++;
		input2/=2;
		j++;
	}

	if(count==1)
		suc2=1;

	int row1=0,row2=0;
	int len1=i,len2=j;

	i--;
	j--;
	while(bin1[i])
	{
		row1++;
		i--;
	}

	while(bin2[j])
	{
		row2++;
		j--;
	}

	int sum=0;
	if(len1!=len2)
	{
		int tmp1=len1-row1;
		int tmp2=row2-1;
		if(suc2)
			tmp2++;

		for(len1=len1+1;len1<len2;len1++)
			sum+=(len1-1);

		sum+=(tmp1+tmp2);
	}
	else
	{
		int tmp1=row1-1;
		int tmp2=row2-1;
		if(suc2)
			tmp2++;

		sum=tmp2-tmp1;
	}
	printf("%d\n",sum);
}

#include <stdio.h>

int main()
{
    int i, Ans = 0;
    unsigned long long a, b;
    scanf("%I64d %I64d", &a, &b);
    for(i = 0; i < 64; ++i) {
        unsigned long long c = 0xffffffffffffffff;
        c ^= 1 << i;
        if(c >= a && c <= b) {
            ++Ans;
        }
    }
    printf("%d\n", Ans);
    return 0;
}

//我服了这个问题了，我需要做得很精细！
#include<stdio.h>
unsigned long long binary_digit(unsigned long long n) {
	unsigned long long count=0;
	while(n>0) {
		n/=2;
		count++;
	}
	return count;
}
unsigned long long sum_to(unsigned long long a,unsigned long long b) {
	return (a+b)*(b-a+1)/2;
}
int main() {
	//读入起始年份和结束年份
	unsigned long long first_year,last_year;
	scanf("%lld%lld",&first_year,&last_year);
	/*
	printf("first year = %lld\n",first_year);
	printf("last year  = %lld\n",last_year);
	*/

	//获得起始年份和结束年份的二进制位数
	unsigned long long first_year_binary_digit=binary_digit(first_year);
	unsigned long long last_year_binary_digit=binary_digit(last_year);

	/*
	printf("\nfirst year binary digit = %d\n",first_year_binary_digit);
	printf("last year  binary digit = %d\n",last_year_binary_digit);
	*/

	//计算分两种情况
	//情况一first year 与 last year 的二进制位数相同！
	//情况二first year 与 last year 的二进制位数不相同！
	//变量不初始化，问题比较严重！
	unsigned long long possible;//没有初始化这个变量为什么会出现不同编译器的不同解答？
	unsigned long long base;
	unsigned long long one=1;//我所有的二进制操作都必须在64位上进行！
	//而且我所有的比较都必须是64位unsigned long long数据之间的比较
	//如果是long long之间的比较可能会出问题
	//就是我产生的可能是signed long long下的负数，负数之间比较就无法得到我想要的结果！
	unsigned long long result=0;
	unsigned long long i=0;
	if(first_year_binary_digit==last_year_binary_digit) {
		base=0;
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		unsigned long long count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year && possible<=last_year) count++;
			//printf("possible = %llx,%llu\n",possible,possible);
			/*
			printf("possible = %llx,%llu\n",first_year,first_year);
			printf("possible = %llx,%llu\n",last_year,last_year);
			*/
		}
		//printf("%d\n",count);
		result=count;

	} else {
		//分三个部分计算
		//第一部分与first year二进制位数相同的有多少个！
		//第二部分与last year二进制位数相同的有多少个！
		//第三部分在first year与last year之间的二进制位数有多少个！
		unsigned long long part1=0;
		//base=0;//我忽略了这个条件！
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year) part1++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 1 = %d\n\n",count);

		unsigned long long part3=0;
		base=0;
		for(i=0;i<last_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<last_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible<=last_year) part3++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 3 = %d\n",count);

		unsigned long long part2;
		if(first_year_binary_digit+1==last_year_binary_digit) {
			part2=0;
		}else {
			part2=sum_to(first_year_binary_digit,last_year_binary_digit-2);
		}

		//printf("part 2 = %lld\n",part2);
		/*
		printf("%lld\n",part1+part2+part3);
		*/
		result=part1+part2+part3;
		//printf("result  = %lld\n",result);
	}
	printf("%lld\n",result);
	return 0;
}

//我服了这个问题了，我需要做得很精细！
#include<stdio.h>
unsigned long long binary_digit(unsigned long long n) {
	unsigned long long count=0;
	while(n>0) {
		n/=2;
		count++;
	}
	return count;
}
unsigned long long sum_to(unsigned long long a,unsigned long long b) {
	return (a+b)*(b-a+1)/2;
}
int main() {
	//读入起始年份和结束年份
	unsigned long long first_year,last_year;
	scanf("%lld%lld",&first_year,&last_year);
	/*
	printf("first year = %lld\n",first_year);
	printf("last year  = %lld\n",last_year);
	*/

	//获得起始年份和结束年份的二进制位数
	unsigned long long first_year_binary_digit=binary_digit(first_year);
	unsigned long long last_year_binary_digit=binary_digit(last_year);

	/*
	printf("\nfirst year binary digit = %d\n",first_year_binary_digit);
	printf("last year  binary digit = %d\n",last_year_binary_digit);
	*/

	//计算分两种情况
	//情况一first year 与 last year 的二进制位数相同！
	//情况二first year 与 last year 的二进制位数不相同！
	unsigned long long possible;
	unsigned long long base;
	unsigned long long one=1;//我所有的二进制操作都必须在64位上进行！
	//而且我所有的比较都必须是64位unsigned long long数据之间的比较
	//如果是long long之间的比较可能会出问题
	//就是我产生的可能是signed long long下的负数，负数之间比较就无法得到我想要的结果！
	unsigned long long result=0;
	unsigned long long i;
	if(first_year_binary_digit==last_year_binary_digit) {
		base=0;
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		unsigned long long count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year && possible<=last_year) count++;
			//printf("possible = %llx,%llu\n",possible,possible);
			/*
			printf("possible = %llx,%llu\n",first_year,first_year);
			printf("possible = %llx,%llu\n",last_year,last_year);
			*/
		}
		//printf("%d\n",count);
		result=count;

	} else {
		//分三个部分计算
		//第一部分与first year二进制位数相同的有多少个！
		//第二部分与last year二进制位数相同的有多少个！
		//第三部分在first year与last year之间的二进制位数有多少个！
		unsigned long long part1=0;
		for(i=0;i<first_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible>=first_year) part1++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 1 = %d\n\n",count);

		unsigned long long part3=0;
		base=0;
		for(i=0;i<last_year_binary_digit;i++) {
			base=base | (one<<i);
		}
		//printf("base = %llx\n",base);
		for(i=0;i<last_year_binary_digit-1;i++) {
			possible = base ^(one<<i);
			if(possible<=last_year) part3++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		//printf("part 3 = %d\n",count);

		unsigned long long part2;
		if(first_year_binary_digit+1==last_year_binary_digit) {
			part2=0;
		}else {
			part2=sum_to(first_year_binary_digit,last_year_binary_digit-2);
		}

		//printf("part 2 = %lld\n",part2);
		/*
		printf("%lld\n",part1+part2+part3);
		*/
		result=part1+part2+part3;
		//printf("result  = %lld\n",result);
	}
	printf("%lld\n",result);
	return 0;
}

//我服了这个问题了，我需要做得很精细！
#include<stdio.h>
int binary_digit(unsigned long long n) {
	int count=0;
	while(n>0) {
		n/=2;
		count++;
	}
	return count;
}
unsigned long long sum_to(unsigned long long a,unsigned long long b) {
	return (a+b)*(b-a+1)/2;
}
int main() {
	//读入起始年份和结束年份
	unsigned long long first_year,last_year;
	scanf("%lld%lld",&first_year,&last_year);
	/*
	printf("first year = %lld\n",first_year);
	printf("last year  = %lld\n",last_year);
	*/

	//获得起始年份和结束年份的二进制位数
	int first_year_binary_digit=binary_digit(first_year);
	int last_year_binary_digit=binary_digit(last_year);
	/*
	printf("first year binary digit = %d\n",first_year_binary_digit);
	printf("last year  binary digit = %d\n",last_year_binary_digit);
	*/

	//计算分两种情况
	//情况一first year 与 last year 的二进制位数相同！
	//情况二first year 与 last year 的二进制位数不相同！
	unsigned long long possible;
	unsigned long long need;
	unsigned long long one=1;//我所有的二进制操作都必须在64位上进行！
	//而且我所有的比较都必须是64位unsigned long long数据之间的比较
	//如果是long long之间的比较可能会出问题
	//就是我产生的可能是signed long long下的负数，负数之间比较就无法得到我想要的结果！
	unsigned long long result;
	if(first_year_binary_digit==last_year_binary_digit) {
		int i;
		need=0;
		for(i=0;i<first_year_binary_digit;i++) {
			need=need | (one<<i);
		}
		//printf("need = %llx\n",need);
		int count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = need ^(one<<i);
			if(possible>=first_year && possible<=last_year) count++;
			/*
			printf("possible = %llx,%llu\n",possible,possible);
			printf("possible = %llx,%llu\n",first_year,first_year);
			printf("possible = %llx,%llu\n",last_year,last_year);
			*/
		}
		//printf("%d\n",count);
		result=count;

	}else {
		//分三个部分计算
		//第一部分与first year二进制位数相同的有多少个！
		//第二部分与last year二进制位数相同的有多少个！
		//第三部分在first year与last year之间的二进制位数有多少个！
		unsigned long long part1=0;
		int i;
		for(i=0;i<first_year_binary_digit;i++) {
			need=need | (one<<i);
		}
		//printf("need = %llx\n",need);
		int count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = need ^(one<<i);
			if(possible>=first_year) count++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		part1=count;
		//printf("part 1 = %d\n",count);

		unsigned long long part3=0;
		need=0;
		for(i=0;i<last_year_binary_digit;i++) {
			need=need | (one<<i);
		}
		//printf("need = %llx\n",need);
		count=0;
		for(i=0;i<last_year_binary_digit-1;i++) {
			possible = need ^(one<<i);
			if(possible<=last_year) count++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		part3=count;
		//printf("part 3 = %d\n",count);

		unsigned long long part2;
		if(first_year_binary_digit+1==last_year_binary_digit) {
			part2=0;
		}else {
			part2=sum_to(first_year_binary_digit,last_year_binary_digit);
		}

		/*
		printf("part 2 = %lld\n",part2);
		printf("%lld\n",part1+part2+part3);
		*/
		result=part1+part2+part3;
	}
	printf("%lld\n",result);
	return 0;
}

//我服了这个问题了，我需要做得很精细！
#include<stdio.h>
int binary_digit(unsigned long long n) {
	int count=0;
	while(n>0) {
		n/=2;
		count++;
	}
	return count;
}
unsigned long long sum_to(unsigned long long a,unsigned long long b) {
	return (a+b)*(b-a+1)/2;
}
int main() {
	//读入起始年份和结束年份
	unsigned long long first_year,last_year;
	scanf("%lld%lld",&first_year,&last_year);
	/*
	printf("first year = %lld\n",first_year);
	printf("last year  = %lld\n",last_year);
	*/

	//获得起始年份和结束年份的二进制位数
	int first_year_binary_digit=binary_digit(first_year);
	int last_year_binary_digit=binary_digit(last_year);

	/*
	printf("\nfirst year binary digit = %d\n",first_year_binary_digit);
	printf("last year  binary digit = %d\n",last_year_binary_digit);
	*/

	//计算分两种情况
	//情况一first year 与 last year 的二进制位数相同！
	//情况二first year 与 last year 的二进制位数不相同！
	unsigned long long possible;
	unsigned long long need;
	unsigned long long one=1;//我所有的二进制操作都必须在64位上进行！
	//而且我所有的比较都必须是64位unsigned long long数据之间的比较
	//如果是long long之间的比较可能会出问题
	//就是我产生的可能是signed long long下的负数，负数之间比较就无法得到我想要的结果！
	unsigned long long result;
	if(first_year_binary_digit==last_year_binary_digit) {
		int i;
		need=0;
		for(i=0;i<first_year_binary_digit;i++) {
			need=need | (one<<i);
		}
		//printf("need = %llx\n",need);
		int count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = need ^(one<<i);
			if(possible>=first_year && possible<=last_year) count++;
			//printf("possible = %llx,%llu\n",possible,possible);
			/*
			printf("possible = %llx,%llu\n",first_year,first_year);
			printf("possible = %llx,%llu\n",last_year,last_year);
			*/
		}
		//printf("%d\n",count);
		result=count;

	}else {
		//分三个部分计算
		//第一部分与first year二进制位数相同的有多少个！
		//第二部分与last year二进制位数相同的有多少个！
		//第三部分在first year与last year之间的二进制位数有多少个！
		unsigned long long part1=0;
		int i;
		for(i=0;i<first_year_binary_digit;i++) {
			need=need | (one<<i);
		}
		//printf("need = %llx\n",need);
		int count=0;
		for(i=0;i<first_year_binary_digit-1;i++) {
			possible = need ^(one<<i);
			if(possible>=first_year) count++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		part1=count;
		//printf("part 1 = %d\n\n",count);

		unsigned long long part3=0;
		need=0;
		for(i=0;i<last_year_binary_digit;i++) {
			need=need | (one<<i);
		}
		//printf("need = %llx\n",need);
		count=0;
		for(i=0;i<last_year_binary_digit-1;i++) {
			possible = need ^(one<<i);
			if(possible<=last_year) count++;
			//printf("possible = %llx,%lld\n",possible,possible);
		}
		part3=count;
		//printf("part 3 = %d\n",count);

		unsigned long long part2;
		if(first_year_binary_digit+1==last_year_binary_digit) {
			part2=0;
		}else {
			part2=sum_to(first_year_binary_digit,last_year_binary_digit-2);
		}

		//printf("part 2 = %lld\n",part2);
		/*
		printf("%lld\n",part1+part2+part3);
		*/
		result=part1+part2+part3;
	}
	printf("%lld\n",result);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007

int cmpfunc(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int min(int a,int b){
	return (a>b)?b:a;
}

int
main(int argc, char *argv[]) {
	long long a,b;
    scanf("%lld %lld",&a,&b);
    int sa[100],sb[100];
    int i=0;
    while(a>0){
        sa[i]=a%2;
        a/=2;
        i++;
    }
    int j=0;
    while(b>0){
        sb[j]=b%2;
        b/=2;
        j++;
    }
    int k;
    int len_a=i,len_b=j;
    long long ans=0;
    if(len_a==len_b) {
        for(i=len_a-1;i>=0;i--){
            if(sa[i]==sb[i] && sa[i]==1) ;
            else break;
        }
        if(i<0) {ans=0;}
        else{
            if(sa[i]==sb[i] && sa[i]==0){
                for(j=i-1;j>=0;j--){
                    if(sb[j]==0) {ans=0;break;}
                }
                if(j<0) {ans++;}
            } else{
                for(j=i-1;j>=0;j--){
                    if(sb[j]==0) break;
                }
                if(j>=0){
                    ans=i-j;
                    for(k=j-1;k>=0;k--){
                        if(sb[k]==0) break;
                    }
                    if(k<0) {ans++;}
                } else {ans=i+1;}
            }
        }
    } else {
        for(i=len_a-1;i>=0;i--){
            if(sa[i]==0) break;
        }
        if(i>=0){
            ans=i+1;
        }
        for(i=len_a+1;i<len_b;i++)
            {ans+=i-1;}
        //consider len_b only
        for(i=len_b-1;i>=0;i--){
            if(sb[i]==0) break;
        }
        if(i<0) {ans+=len_b;}
        else{
            ans+=len_b-2-i;
            for(k=i-1;k>=0;k--){
                if(sb[k]==0) break;
            }
            if(k<0) {ans++;}
        }
    }
    printf("%lld\n",ans);
	return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int cmpfunc(const void * a, const void * b)
{
    if (*(long long int*)a > *(long long int*)b )
        return 1;
    else if (*(long long int*)a == *(long long int*)b )
        return 0;
    else
        return -1;
}

long long int convert(int start, int pos) {
    return pow(2,start+1) - 1 - pow (2,pos);
}

int find(long long int * result, int count, long long int e) {
    int i;
    for (i=0;i<count;i++) {
        if (result[i] >= e )
            break;
    }
    return i - 1;
}

int main(void) {
    // your code goes here
    long long int a, b;
    long long int result[2000];
    int indexA, indexB, count = 0, start, pos, i;

    for (start = 0; start <60; start++) {
        for (pos = 0; pos <=start-1; pos++) {
            result[count++] = convert(start, pos);
        }
    }

    qsort(result, count, sizeof(long long int), cmpfunc);

    while(scanf("%lld %lld", &a, &b)!=-1) {
        indexA = find(result, count, a);
        indexB = find(result, count, b);
        printf("%d\n", indexB - indexA);
    }

    return 0;
}

#include<stdio.h>
long long int v[2000];
int main(){
    int l,i,r,j;
    long long int x,y;
    scanf("%I64d %I64d",&x,&y);
    for(i=l=0;i<60;i++){
        for(j=i-1;~j;j--){
            for(r=0;r<=i;r++){
                v[l]|=(long long int)(j!=r)<<(r);
            }
            l++;
        }
    }
    printf("%d ",l);
    i=r=0;
    while(v[i]<x){
        i++;
    }
    while(v[i]<=y){
        i++;
        r++;
    }
    printf("%d",r);
    return 0;
}

/**Bismillahir Rahamnir Rahim.**/

#include <stdio.h>
int main()
{
    long long int a, b, c, i, lnth_a, lnth_b, ans,tmp, indx1, indx2, cnt=0;
    char aa[300], bb[300];
    scanf("%I64d%I64d", &a, &b);
    for(i=0; a!=0; i++)
    {
        c = a%2;
        aa[i] = c+48;
        a/=2;
    }
    aa[i] = '\0';
    for(i=0; b!=0; i++)
    {
        c = b%2;
        bb[i] = c+48;
        b/=2;
    }
    bb[i] = '\0';
    lnth_a = strlen(aa);
    lnth_b = strlen(bb);
    for(i=lnth_a-1, indx1=0; i>=0; i--)
    {
        if(aa[i] == '0')
        {
            indx1 = lnth_a-(i+1);
            indx1 = lnth_a - indx1;
            break;
        }
    }
    for(i=lnth_b-1, indx2=lnth_b-1; i>=0; i--)
    {
        if(bb[i] == '0')
        {
            indx2 = lnth_b-(i+1);
            indx2 = indx2 - 1;
            break;
        }
    }
    for(i=0, cnt=0; bb[i]; i++)
    {
        if(bb[i] == '0') cnt++;
    }
    if(cnt==1) indx2++;
    if(lnth_a==lnth_b)
    {
        tmp = lnth_a-1;
        ans = (indx1+indx2)-tmp;
        printf("%I64d\n", ans);
        return 0;
    }
    else
    {
        tmp = lnth_b - lnth_a;
        if(tmp == 1)
        {
            printf("%I64d\n", indx1+indx2);
            return 0;
        }
        for(i = lnth_a+1, ans=0; i<lnth_b; i++)
        {
            ans+= (i-1);
            tmp = lnth_a-1;
            ans += ((indx1+indx2)-tmp);
            printf("%I64d\n", ans);
            return 0;
        }
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

typedef unsigned long long int llu;

int numberOfZeros(llu num, size_t const size){
	int i, result, temp;
	for(i = 0, result = 0, temp = 0; i < size*8; i++){
		// printf("%llu\n", num);
		if(num%2 == 0){
			temp++;
		} else {
			result += temp;
			temp = 0;
		}
		num = num >> 1;
		// printBits(sizeof(num), &num);
	}

	return result;
}

void printBits(size_t const size, void const * const ptr)
{
    unsigned char *b = (unsigned char*) ptr;
    unsigned char byte;
    int i, j;

    for (i=size-1;i>=0;i--)
    {
        for (j=7;j>=0;j--)
        {
            byte = b[i] & (1<<j);
            byte >>= j;
            printf("%u", byte);
        }
    }
    puts("");
}

int findMax(llu* b){
	int i;
	llu max = 1, mask = 3;
	max = ~(max << (sizeof(max)*8 - 2));

	for(i = 0; i < sizeof(max)*8; i++){
		if(max <= *b){
			break;
		}
		max = max >> 1;
	}

	mask = mask << (61 - i);
	for(; (max ^ mask) <= *b && i < 62; max = max ^ mask, mask = mask >> 1, i++);

	*b = max;

	return 62 - i;
}

int findMin(llu *a, llu b){
	int i;
	llu min;

	for(min = *a; min < b; min++){
		if(numberOfZeros(min, sizeof(min)) == 1){
			break;
		}
	}

	*a = min;

	for(i = 0; i < 8*sizeof(min); i++){
		if(min%2 == 0){
			break;
		}
		min = min >> 1;
	}

	return i;
}

int len(llu a){
	int temp, i, result;

	for(i = 0, temp = 0, result = 0; i < 8*sizeof(a); i++, temp++, a = a >> 1){
		if(a%2 != 0){
			result += temp;
			temp = 0;
		}
	}

	return ++result;
}

int main(){
	llu i, a, b, ta, tb, result = 0;
	int pa, pb;

	scanf("%llu %llu", &a, &b);
	ta = a;
	tb = b;

	pb = findMax(&tb);
	pa = findMin(&ta, tb);

	if(ta >= a && tb <= b && ta <= tb){
		for(i = len(ta); i <= len(tb); i++){
			result += i - 1;
		}

		result -= pb;
		result -= len(ta) - 2 - pa;
	}

	printf("%llu", result);
	return 0;
}
// 1453787442792

#include<stdio.h>
typedef long long int ll;
int main()
{
	ll i,j,a,b,c;
	scanf("%I64d%I64d",&a,&b);
	ll cnt=0;
	for(i=0;1LL<<i<=2*b;i++)
	{
	//	printf("%Ld\n",i);
		ll res;
		ll tmp=1LL<<i-1;
		for(j=0;j<=i-2;j++)
		{
			//printf("%Ld\t%Ld\t%Ld\n",i,1LL<<i,1LL<<j);
			res=tmp-(1LL<<j);
			//printf("%Ld\t%Ld\n",i,res);
			if(res>=a&res<=b)
			{
				cnt++;
			}
		}
	}
	printf("%I64d\n",cnt);
}

#include<stdio.h>
typedef long long int ll;
int main()
{
	ll i,j,a,b,c;
	scanf("%Ld%Ld",&a,&b);
	ll cnt=0;
	for(i=0;1LL<<i<=2*b;i++)
	{
	//	printf("%Ld\n",i);
		ll res;
		ll tmp=1LL<<i-1;
		for(j=0;j<=i-2;j++)
		{
			//printf("%Ld\t%Ld\t%Ld\n",i,1LL<<i,1LL<<j);
			res=tmp-(1LL<<j);
			//printf("%Ld\t%Ld\n",i,res);
			if(res>=a&res<=b)
			{
				cnt++;
			}
		}
	}
	printf("%Ld\n",cnt);
}

#include <stdio.h>
#include <math.h>

#define Max 10000

int main()
{
    long long num[Max], tmp = 1, cur = 0, k = 0, cont, a, b;
    int i, j, l;

    for (i = 2; i <= 64; i++)
    {
        tmp = tmp << 1;
        tmp = tmp | 1;
        //printf("tmp = %I64d\n", tmp);
        for (j = 0; j < i-1; j++)
        {
            cur = tmp-pow(2,j);
            num[k++] = cur;
            //printf("%I64d\n", cur);
//            for (l = 1; l <= 64; l++)
//            {
//                printf("%I64d", cur&1);
//                cur = cur >> 1;
//            }
//            printf("\n");
            //system("pause");
        }
    }
    num[k] = tmp-pow(2,63);
    while (scanf("%I64d%I64d", &a, &b) != EOF)
    {
        cont = 0;
        for (i = 0; i <= k; i++)
        {
            if (num[i] >= a && num[i] <= b)
            {
                cont++;
            }
        }
        printf("%I64d\n", cont);
    }
    return 0;
}

#include <stdio.h>
#define Max 10000

int main()
{
    long long num[Max], tmp = 1, cur = 0, k = 0, cont, a, b;
    int i, j;

    for (i = 2; i <= 64; i++)
    {
        tmp = tmp << 1;
        tmp = tmp | 1;
        for (j = 0; j < i-1; j++)
        {
            cur = tmp-pow(2,j);
            num[k++] = cur;
        }
    }
    while (scanf("%I64d%I64d", &a, &b) != EOF)
    {
        cont = 0;
        for (i = 0; i <= k-1; i++)
        {
            if (num[i] >= a && num[i] <= b)
            {
                cont++;
            }
        }
        printf("%I64d\n", cont);
    }
    return 0;
}

#include <stdio.h>
#include <math.h>

#define Max 10000
long long mpow(int a, int b) {
    long long res = 1;
    int i;
    for ( i = 0; i < b; i++) res *= a;
    return res;
}
int main()
{
    long long num[Max], tmp = 1, cur = 0, k = 0, cont, a, b;
    int i, j, l;

    for (i = 2; i <= 64; i++)
    {
        tmp = tmp << 1;
        tmp = tmp | 1;
        //printf("tmp = %I64d\n", tmp);
        for (j = 0; j < i-1; j++)
        {
            cur = tmp-pow(2,j);
            num[k++] = cur;
            //printf("%I64d\n", cur);
//            for (l = 1; l <= 64; l++)
//            {
//                printf("%I64d", cur&1);
//                cur = cur >> 1;
//            }
//            printf("\n");
            //system("pause");
        }
    }

    num[k] = tmp-mpow(2,63);
    cur = num[k];

    while (scanf("%I64d%I64d", &a, &b) != EOF)
    {
        cont = 0;
        for (i = 0; i <= k; i++)
        {
            if (num[i] >= a && num[i] <= b)
            {
                cont++;
            }
        }
        printf("%I64d\n", cont);
    }
    return 0;
}

#include <stdio.h>
#include <math.h>

#define Max 10000

int main()
{
    long long num[Max], tmp = 1, cur = 0, k = 0, cont, a, b;
    int i, j, l;

    for (i = 2; i <= 64; i++)
    {
        tmp = tmp << 1;
        tmp = tmp | 1;
        //printf("tmp = %I64d\n", tmp);
        for (j = 0; j < i-1; j++)
        {
            cur = tmp-pow(2,j);
            num[k++] = cur;
            //printf("%I64d\n", cur);
//            for (l = 1; l <= 64; l++)
//            {
//                printf("%I64d", cur&1);
//                cur = cur >> 1;
//            }
//            printf("\n");
            //system("pause");
        }
    }
    num[k] = tmp-pow(2,63);
    while (scanf("%I64d%I64d", &a, &b) != EOF)
    {
        cont = 0;
        for (i = 0; i <= k-1; i++)
        {
            if (num[i] >= a && num[i] <= b)
            {
                cont++;
            }
        }
        printf("%I64d\n", cont);
    }
    return 0;
}

#include <stdio.h>
long long int power(long long int x,long long int y)
{
	if(y==0)
		return 1;
	else if(y%2==0)
		return power(x,y/2)*power(x,y/2);
	else
		return x*power(x,y/2)*power(x,y/2);
}
int cmpfunc (const void * a, const void * b)
{
	return ( *(int*)a - *(int*)b );
}
int main()
{
	long long int n,i,j,a[2484],l=0,count=0,b,c;
	scanf("%lld %lld",&b,&c);
	for(i=2;i<=70;i++)
	{
		for(j=i-2;j>=0;j--)
		{
			a[l]=power(2,i)-1-power(2,j);
/*			if(a[l]==2015)
			{
				printf("%lld %lld\n",i,j);
				printf("yes\n");
			}*/
//			printf("%lld\n",a[l]);
			l++;
		}
	}
	qsort(a, 2484, sizeof(long long int), cmpfunc);
	for(i=0;i<2484;i++)
	{
		if(b<=a[i] && a[i]<=c && a[i]!=a[i+1])
		{
//			printf("%lld\n",a[i]);
			count++;
		}
	}
	printf("%lld\n",count);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
long long int power(long long int x,long long int y)
{
	if(y==0)
		return 1;
	else if(y%2==0)
		return power(x,y/2)*power(x,y/2);
	else
		return x*power(x,y/2)*power(x,y/2);
}
int cmpfunc (const void * a, const void * b)
{
	return ( *(int*)a - *(int*)b );
}
int main()
{
	long long int n,i,j,a[2484],l=0,count=0,b,c;
	scanf("%lld %lld",&b,&c);
	for(i=2;i<=70;i++)
	{
		for(j=i-2;j>=0;j--)
		{
			a[l]=power(2,i)-1-power(2,j);
			l++;
		}
	}
	qsort(a, 2484, sizeof(long long int), cmpfunc);
	for(i=0;i<2484;i++)
	{
		if(b<=a[i] && a[i]<=c && a[i]!=a[i+1])
		{
			count++;
		}
	}
	printf("%lld\n",count);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	long long int a,b;
	scanf("%lld%lld", &a,&b);

	int n,m,i,j;

	for(i=0;;i++)
	{
		if((pow(2,i))>a)
		{
			n=i;
			break;
		}
	}

	for(i=0;;i++)
	{
		if((pow(2,i))>b)
		{
			m=i;
			break;
		}
	}

	long long int count=0;

	for(i=n;i<=m;i++)
	{
		for(j=0;j<i-1;j++)
		{
			long long int k=pow(2,i)-1;
			long long int l=pow(2,j);

			if((pow(2,i)-1-pow(2,j))>=a && (pow(2,i)-1-pow(2,j))<=b)
			{
				count++;
			}
		}
	}

	printf("%lld", count);

	return 0;
}