#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 100;
long long l, r, x, a[N], dp[N];
long long f(int size, int group, bool w) {
  if (w) return 1LL << size - 1;
  long long cnt = 0;
  for (int i = 1; i <= size; i++) cnt = cnt * 2 + a[i];
  long long sum = 0;
  for (int i = 1; i <= group; i++) sum = (sum << size) + cnt;
  return cnt - (1LL << size - 1) + 1 - (sum > x);
}
long long calc(long long n, bool w) {
  long long ans = 0;
  for (int i = 1; i <= n - 1; i++) {
    if (n % i == 0) {
      dp[i] = f(i, n / i, w);
      for (int j = 1; j <= i - 1; j++)
        if (i % j == 0) dp[i] -= dp[j];
      ans += dp[i];
    }
  }
  return ans;
}
long long solve(long long x) {
  if (x == 0) return 0;
  ::x = x;
  long long n = 0;
  while (x) {
    a[++n] = x % 2;
    x /= 2;
  }
  reverse(a + 1, a + n + 1);
  long long ans = 0;
  for (int i = 1; i <= n - 1; i++) ans += calc(i, 1);
  ans += calc(n, 0);
  return ans;
}
int main() {
  cin >> l >> r;
  cout << solve(r) - solve(l - 1) << '\n';
  return 0;
}
