/* 2013-07-26 09:55:09.910531 */#include<cstdio>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

#define MP make_pair
#define PB push_back
#define foreach(e,x) for(__typedef(x.begin()) e=x.begin(); e!=x.end(); ++e)

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> mapII;

const int MAX_N = 100 + 10;
const double EPS = 1e-8;

LL l, r;
LL f[MAX_N];
LL p2[MAX_N];
int mu[MAX_N], prime[MAX_N];

void prepare()
{
	p2[0] = 1;
	for(int i = 1; i < 64; ++ i) {
		p2[i] = p2[i - 1] * 2;
	}

	mu[1] = 1; prime[1] = false;
	for(int i = 2; i < 64; ++ i) {
		prime[i] = true;
		for(int j = 2; j < i; ++ j) {
			if (i % j == 0)
				prime[i] = false;
		}

		int flag = false;
		for(int j = 2; j < i; ++ j) {
			if (i % (j * j) == 0) {
				mu[i] = 0;
				flag = true;
			}
		}
		if (flag) continue;
		mu[i] = -1;
		for(int j = 2; j <= i; ++ j) {
			if (i % j == 0 && prime[j])
				mu[i] = mu[i] * (-1);
		}
	}

	for(int i = 1; i <= 64; ++ i) {
		for(int j = 1; j < i; ++ j) {
			if (i % j) continue;
			f[i] += p2[j - 1];
			for(int k = 1; k < j; ++ k) {
				if (j % k) continue;
				f[i] -= f[k];
			}
		}
	}
}

int x[100], tot;
LL dp[100];

LL calc(LL a)
{
	tot = 0;
	do {
		x[tot ++] = a % 2;
		a /= 2;
	} while (a);
	reverse(x, x + tot);

	LL ret = 0;
	
	for(int i = 1; i < tot; ++ i) {
		if (tot % i) continue;
		dp[i] = 0;
		for(int j = 1; j < i; ++ j) {
			if (i % j) continue;
			dp[i] -= dp[j];
		}
		for(int j = 1; j < i; ++ j) {
			if (x[j] == 0) continue;
			dp[i] += p2[i - j - 1];
		}
		int flag = true;
		for(int j = 0; j < tot; ++ j) {
			if (x[j] == x[j % i]) continue;
			if (x[j] > x[j % i]) break;
			flag = false;
			break;
		}
		dp[i] += flag;
		ret += dp[i];
	}
	return ret;
}

LL getAns(LL a)
{
	int tot = 0;
	LL t = a;
	LL ret = 0;
	do {
		x[tot ++] = a % 2;
		a /= 2;
	} while (a);
	LL cur = 0;
	for(int i = 1; i < tot; ++ i) {
		cur = cur * 2 + 1;
		ret += calc(cur);
	}
	ret += calc(t);
	return ret;
}

void solve()
{
	cin >> l >> r;
	LL sl = getAns(l - 1), sr = getAns(r);
	cout << sr - sl << endl;
}

int main()
{
	prepare();
	solve();
	return 0;
}

