#include <bits/stdc++.h>
using namespace std;
long long g[32];
vector<int> 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 mu[65];
long long dp[65];
void precalc() {
  mu[1] = 1;
  for (int i = 2; i < 65; ++i) {
    mu[i] = 1;
    int ii = i;
    for (int j = 2; j <= ii; ++j) {
      if (ii % j != 0) continue;
      ii /= j;
      mu[i] *= -1;
      if (ii % j == 0) {
        mu[i] = 0;
        break;
      }
    }
  }
  dp[1] = 2;
  for (int i = 2; i < 65; ++i) {
    for (int j = 2; j <= i; ++j) {
      if (i % j) continue;
      dp[i] += -mu[j] * (1LL << (i / 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));
    ans += g[i] * -mu[l / i];
  }
  return ans;
}
int main() {
  prec();
  precalc();
  long long l, r;
  cin >> l >> r;
  cout << f(r) - f(l - 1);
  return 0;
}
