#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
long long int solve(int len, string pref) {
  if (pref.empty()) pref = "1";
  map<int, int> moe;
  vector<int> factor;
  int tmp = len;
  for (int i = 2; i * i <= tmp; ++i)
    if (tmp % i == 0) {
      factor.push_back(i);
      while (tmp % i == 0) tmp /= i;
    }
  if (tmp > 1) factor.push_back(tmp);
  int m = factor.size();
  for (int i = 1; i < 1 << m; ++i) {
    int d = 1, s = -1;
    for (int j = 0; j < m; ++j)
      if (i >> j & 1) {
        d *= factor[j];
        s *= -1;
      }
    moe[d] = s;
  }
  __typeof(moe.begin()) it = moe.begin();
  long long int res = 0;
  while (it != moe.end()) {
    int len2 = len / it->first;
    if (len2 >= pref.size()) {
      res += (1ll << (len2 - pref.size())) * it->second;
    } else {
      int flag = 0;
      for (int i = 0; i < pref.size(); ++i)
        if (pref[i % len2] != pref[i]) {
          flag = 1;
          break;
        }
      if (!flag) res += it->second;
    }
    ++it;
  }
  return res;
}
long long int solve2(long long int a) {
  string s;
  while (a) {
    s += ((a & 1) + '0');
    a >>= 1;
  }
  reverse((s).begin(), (s).end());
  long long int res = 0;
  for (int i = 1; i < s.size(); ++i) res += solve(i, "");
  for (int i = 1; i < s.size(); ++i)
    if (s[i] == '1') {
      res += solve(s.size(), s.substr(0, i) + "0");
    }
  return res;
}
int main() {
  long long int l, r;
  cin >> l >> r;
  cout << solve2(r + 1) - solve2(l) << endl;
  return 0;
}
