#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define VI vector <int>
#define clr(x) memset((x),0,sizeof(x))
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define pw(x) (1ll<<(x))
typedef long long ll;
ll g[32];
ll pr_ans[63];
VI divs[63];
inline void upd(int i)
{
fori(j,divs[i])
g[i]-=g[*j];
}
void prec()
{
for(int i = 1;i < 61;i++)
{
for(int j=1;j * j <= i && j < i;j++)
if (i%j==0)
{
divs[i].pb(j);
int d = i / j;
if (d != j && d < i)
divs[i].pb(d);
}
sort(divs[i].begin(),divs[i].end());
}
clr(g);
for(int i=1;i<31;i++)
{
g[i] = pw(i-1);
upd(i);
}
clr(pr_ans);
for(int i=1;i<61;i++)
{
pr_ans[i] = pr_ans[i-1];
fori(j,divs[i])
pr_ans[i] += g[*j];
}
}
inline int lg(ll n)
{
int l = 0;
while (n)
{
l++;
n>>=1;
}
return l;
}
ll f(ll n)
{
if (n <= 1) return 0;
ll ans = 0;
int l = lg(n);
ans += pr_ans[l-1];
clr(g);
fori(it, divs[l])
{
int i = *it;
ll t = n >> (l-i);
ll p = t;
forn(j,l/i-1)
p = (p << i) + t;
if (p <= n) g[i]++;
g[i] += t - pw(i-1);
upd(i);
ans += g[i];
}
return ans;
}
int main()
{
prec();
ll l,r;
cin >> l >> r;
cout << f(r) - f(l-1);
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxjdGltZT4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxpb3N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mQoKSk7CiAgICB9CiAgICBjbHIoZyk7CiAgICBmb3IoaW50IGk9MTtpPDMxO2krKykKICAgIHsKICAgICAgICBnW2ldID0gcHcoaS0xKTsKICAgICAgICB1cGQoaSk7CiAgICB9CgogICAgY2xyKHByX2Fucyk7CiAgICBmb3IoaW50IGk9MTtpPDYxO2krKykKICAgIHsKICAgICAgICBwcl9hbnNbaV0gPSBwcl9hbnNbaS0xXTsKICAgICAgICBmb3JpKGosZGl2c1tpXSkKICAgICAgICAgICAgcHJfYW5zW2ldICs9IGdbKmpdOwogICAgfQp9CmlubGluZSBpbnQgbGcobGwgbikKewogICAgaW50IGwgPSAwOwogICAgd2hpbGUgKG4pCiAgICB7CiAgICAgICAgbCsrOwogICAgICAgIG4+Pj0xOwogICAgfQogICAgcmV0dXJuIGw7Cn0KCmxsIGYobGwgbikKewogICAgaWYgKG4gPD0gMSkgcmV0dXJuIDA7CiAgICBsbCBhbnMgPSAwOwogICAgaW50IGwgPSBsZyhuKTsKICAgIGFucyArPSBwcl9hbnNbbC0xXTsKICAgIGNscihnKTsKICAgIGZvcmkoaXQsIGRpdnNbbF0pCiAgICB7CiAgICAgICAgaW50IGkgPSAqaXQ7CiAgICAgICAgbGwgdCA9IG4gPj4gKGwtaSk7CiAgICAgICAgbGwgcCA9IHQ7CiAgICAgICAgZm9ybihqLGwvaS0xKQogICAgICAgICAgICBwID0gKHAgPDwgaSkgKyB0OwogICAgICAgIGlmIChwIDw9IG4pIGdbaV0rKzsKICAgICAgICBnW2ldICs9IHQgLSBwdyhpLTEpOwogICAgICAgIHVwZChpKTsKICAgICAgICBhbnMgKz0gZ1tpXTsKICAgIH0KICAgIHJldHVybiBhbnM7Cn0KCmludCBtYWluKCkKewogICAgcHJlYygpOwogICAgbGwgbCxyOwogICAgY2luID4+IGwgPj4gcjsKICAgIGNvdXQgPDwgZihyKSAtIGYobC0xKTsKICAgIHJldHVybiAwOwp9Cg==