#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795L;
const long double EPS = 1e-11;
char TEMPORARY_CHAR;
const long long INF = 1e10;
const int N = 1 << 16;
inline void input(int& a) {
  a = 0;
  while ((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') {
  }
  while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {
    a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0';
    TEMPORARY_CHAR = getchar();
  }
}
inline int nxt() {
  int(ret);
  input((ret));
  ;
  return ret;
}
long long ans[61];
long long g[32];
vector<long long> divs[63];
void prec() {
  for (int i = 1; i < 61; i++)
    for (int j = 1; j < i; j++)
      if (i % j == 0) divs[i].push_back(j);
}
inline int lg(long long n) {
  int l = 0;
  while (n) {
    l++;
    n >>= 1;
  }
  return l;
}
inline void upd(int i) {
  for (__typeof((divs[i]).begin()) j = (divs[i]).begin(); j != (divs[i]).end();
       j++)
    g[i] -= g[*j];
}
long long f(long long n) {
  if (n <= 1) return 0;
  long long ans = 0;
  int l = lg(n);
  ans += f((1ll << (l - 1)) - 1);
  memset((g), 0, sizeof(g));
  for (__typeof((divs[l]).begin()) it = (divs[l]).begin();
       it != (divs[l]).end(); it++) {
    int i = *it;
    long long t = n >> (l - i);
    long long p = t;
    for (int j = 0; j < (int)(l / i - 1); j++) p = (p << i) + t;
    if (p <= n) g[i]++;
    g[i] += t & ((1ll << (i - 1)) - 1);
    upd(i);
    ans += g[i];
  }
  return ans;
}
int main() {
  prec();
  long long l, r;
  cin >> l >> r;
  cout << f(r) - f(l - 1);
  return 0;
}
