#include <bits/stdc++.h>
using namespace std;
const long long N = 60 + 3;
long long dp[N], tav[N], dp2[N];
vector<long long> a;
void check(long long x, long long l) {
  if ((a.size()) % l != 0) {
    dp2[l] = 0;
    return;
  }
  for (long long i = l; i < x; i++) {
    if (a[i] != a[i - l]) return;
  }
  if (x >= l && a[x] == a[x - l]) return;
  dp2[l] += tav[max(0LL, l - x - 1LL)];
}
long long f(long long x) {
  long long z = x, ans = 0;
  a.clear();
  while (z > 0) {
    a.push_back(z % 2);
    z /= 2;
  }
  for (long long i = 1; i < a.size(); i++) ans += dp[i];
  reverse(a.begin(), a.end());
  for (long long i = 1; i < a.size(); i++) {
    if (a[i] == 0) continue;
    memset(dp2, 0, sizeof(dp2));
    for (long long j = 1; j < a.size(); j++) {
      check(i, j);
      ans += dp2[j];
      if (dp2[j]) {
        for (long long l = j + j; l < a.size(); l += j) {
          if (a.size() % l == 0) {
            dp2[l] -= dp2[j];
          }
        }
      }
    }
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long l, r;
  cin >> l >> r;
  tav[0] = 1;
  for (long long i = 1; i < N; i++) tav[i] = tav[i - 1] * 2LL;
  dp[0] = dp[1] = 0;
  for (long long i = 2; i < N; i++) {
    for (long long j = 1; j < i; j++) {
      if (i % j == 0) {
        dp[i] += tav[j - 1] - dp[j];
      }
    }
  }
  cout << f(r + 1) - f(l) << "\n";
  return 0;
}
