#include <bits/stdc++.h>
using namespace std;
long long l, r, f[100];
int x[100];
long long call(long long k) {
  int n = 0;
  long long temp = k;
  while (k != 0) n++, x[n] = k % 2, k /= 2;
  for (int i = 1; i <= n / 2; i++) swap(x[i], x[n + 1 - i]);
  memset(f, 0, sizeof(f));
  long long ss = 0, gg = 0;
  for (int i = 1; i <= n - 1; i++) {
    ss = ss * 2 + x[i];
    if (i >= 2) gg = gg * 2 + x[i];
    if (n % i == 0 && gg >= 1) f[i] += gg;
    long long rr = 0, mu = 1;
    for (int j = 1; j <= i; j++) mu *= 2;
    for (int j = 1; j <= n / i; j++) rr = rr * mu + ss;
    if (rr <= temp) f[i]++;
  }
  long long res = 0;
  for (int i = 1; i <= n - 1; i++)
    if (n % i == 0) {
      for (int j = 1; j <= i - 1; j++)
        if (i % j == 0) f[i] -= f[j];
      res += f[i];
    }
  return res;
}
long long cal(long long k) {
  long long res = call(k);
  int n = 0;
  while (k != 0) n++, k /= 2;
  for (int i = 1; i <= n - 1; i++) res += call((1LL << i) - 1);
  return res;
}
int main() {
  cin >> l >> r;
  cout << cal(r) - cal(l - 1);
  return 0;
}
