#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
inline void zeta(vector<T>& f) {
  for (int n = f.size(), i = n - 1; i >= 1; i--)
    for (int j = i; (j += i) < n;) f[j] += f[i];
}
template <typename T>
inline void mobius(vector<T>& F) {
  for (int n = F.size(), i = 1; i < n; i++)
    for (int j = i; (j += i) < n;) F[j] -= F[i];
}
template <typename T>
inline void zeta_p(vector<T>& f) {
  for (int n = f.size(), i = 1; i < n; i++)
    for (int j = i; (j += i) < n;) f[i] += f[j];
}
template <typename T>
inline void mobius_p(vector<T>& F) {
  for (int n = F.size(), i = n - 1; i >= 1; i--)
    for (int j = i; (j += i) < n;) F[i] -= F[j];
}
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename V>
string to_string(V v) {
  bool f = true;
  string res = "[";
  for (const auto& x : v) {
    if (!f) res += ", ";
    f = false;
    res += to_string(x);
  }
  res += "]";
  return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) {
  cerr << " " << to_string(h);
  debug(t...);
}
ll f(ll msk) {
  if (msk < 3) return 0;
  int n = 64 - __builtin_clzll(msk);
  vector<int> cnt(n + 1);
  for (int i = 1; i <= n / 2; i++) {
    if (n % i != 0) continue;
    ll prefix = msk >> (n - i);
    cnt[i] += prefix - (1ll << (63 - __builtin_clzll(prefix)));
    ll x = prefix;
    for (int j = i; j < n; j += i) {
      x <<= i;
      x |= prefix;
    }
    if (x <= msk) cnt[i]++;
  }
  2019;
  mobius(cnt);
  2019;
  ll sum = 0;
  for (int i = 1; i <= n / 2; i++) {
    if (n % i != 0) continue;
    sum += cnt[i];
  }
  return sum + f((1ll << (n - 1)) - 1);
}
void solve() {
  ll l, r;
  cin >> l >> r;
  cout << f(r) - f(l - 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  cout << endl;
}
