#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];
VI divs[63];
void prec()
{
for(int i=1;i<61;i++)
for(int j=1;j<i;j++)
if (i%j==0)
divs[i].pb(j);
}
inline int lg(ll n)
{
int l = 0;
while (n)
{
l++;
n>>=1;
}
return l;
}
inline void upd(int i)
{
fori(j,divs[i])
g[i]-=g[*j];
}
ll f(ll n)
{
if (n<=1) return 0;
ll ans = 0;
int l = lg(n);
ans+=f(pw(l-1) - 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+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIFZJIHZlY3RvciA8aW50PgojZGVmaW5lIGNscih4KSBtZW1zZXQoKHgpLDAsc2l6ZW9mKHgpKQojZGVmaW5lIGZvcm4oaSwgbikgZm9yKGludCBpPTA7IGk8KGludCkobik7IGkrKykKCiNkZWZpbmUgZm9yaShpdCwgeCkgZm9yIChfX3R5cGVvZigoeCkuYmVnaW4oKSkgaXQgPSAoeCkuYmVnaW4oKTsgaXQgIT0gKHgpLmVuZCgpOyBpdCsrKQoKI2RlZmluZSBwdyh4KSAoMWxsPDwoeCkpCgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmxsIGdbMzJdOwpWSSBkaXZzWzYzXTsKdm9pZCBwcmVjKCkKewogICAgZm9yKGludCBpPTE7aTw2MTtpKyspCiAgICAgICAgZm9yKGludCBqPTE7ajxpO2orKykKICAgICAgICAgICAgaWYgKGklaj09MCkKICAgICAgICAgICAgICAgIGRpdnNbaV0ucGIoaik7Cn0KaW5saW5lIGludCBsZyhsbCBuKQp7CiAgICBpbnQgbCA9IDA7CiAgICB3aGlsZSAobikKICAgIHsKICAgICAgICBsKys7CiAgICAgICAgbj4+PTE7CiAgICB9CiAgICByZXR1cm4gbDsKfQoKaW5saW5lIHZvaWQgdXBkKGludCBpKQp7CiAgICBmb3JpKGosZGl2c1tpXSkKICAgICAgICBnW2ldLT1nWypqXTsKfQoKbGwgZihsbCBuKQp7CiAgICBpZiAobjw9MSkgcmV0dXJuIDA7CiAgICBsbCBhbnMgPSAwOwogICAgaW50IGwgPSBsZyhuKTsKICAgIGFucys9ZihwdyhsLTEpIC0gMSk7CiAgICBjbHIoZyk7CiAgICBmb3JpKGl0LCBkaXZzW2xdKQogICAgewogICAgICAgIGludCBpID0gKml0OwogICAgICAgIGxsIHQgPSBuID4+IChsLWkpOwogICAgICAgIGxsIHAgPSB0OwogICAgICAgIGZvcm4oaixsL2ktMSkKICAgICAgICAgICAgcCA9IChwIDw8IGkpICsgdDsKICAgICAgICBpZiAocCA8PSBuKSBnW2ldKys7CiAgICAgICAgZ1tpXSArPSB0IC0gcHcoaS0xKTsKICAgICAgICB1cGQoaSk7CiAgICAgICAgYW5zICs9IGdbaV07CiAgICB9CiAgICByZXR1cm4gYW5zOwp9CgppbnQgbWFpbigpCnsKICAgIHByZWMoKTsKICAgIGxsIGwscjsKICAgIGNpbiA+PiBsID4+IHI7CiAgICBjb3V0IDw8IGYociktZihsLTEpOwogICAgcmV0dXJuIDA7Cn0K