#include <bits/stdc++.h>
using namespace std;
const int N = 100;
long long a[N], b[N];
long long f(long long x) {
  memset(a, 0, sizeof a);
  memset(b, 0, sizeof b);
  string s;
  long long xx = x, len = 0, ans = 0;
  while (xx) xx >>= 1, len++;
  for (long long i = 2; i < len; i++) {
    a[i]++;
    for (long long j = 2; j < i; j++)
      if (i % j == 0) a[i] += (1 << (j - 1)) - a[j];
    ans += a[i];
  }
  for (long long i = 1; i < len; i++) {
    if (len % i) continue;
    long long p = 0;
    for (long long j = 0; j < len / i; j++) p = (p << i) + (x >> (len - i));
    for (long long j = 60; j > -1; j--) {
      if ((1LL << j) <= (x >> (len - i))) {
        b[i] = (x >> (len - i)) - (1LL << j);
        break;
      }
    }
    if (p <= x) b[i]++;
    for (long long j = 1; j < i; j++)
      if (i % j == 0) b[i] -= b[j];
    ans += b[i];
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long l, r;
  cin >> l >> r;
  cout << f(r) - f(l - 1);
  return 0;
}
