#include <bits/stdc++.h>
using namespace std;
long long L, R;
void init() { cin >> L >> R; }
long long getlen(long long s) {
  long long res = 0;
  while (s) s >>= 1, res++;
  return res;
}
long long calc(long long s, long long len) {
  if (s == 0) return 0;
  long long i, j, res = 0;
  for (i = 1; i <= len - 1; i++) {
    if (len % i != 0) continue;
    long long tmp = s >> (len - i), s2 = tmp;
    for (j = len / i; j >= 2; j--) s2 = (s2 << i) + tmp;
    if (s2 > s) {
      tmp--;
      if (getlen(tmp) != i) continue;
    }
    res += tmp - (1LL << (i - 1)) + 1 - calc(tmp, i);
  }
  return res;
}
long long calc2(long long s) {
  long long tmp = 1, res = 0;
  while (tmp <= s) {
    res += calc(tmp - 1, getlen(tmp - 1));
    tmp <<= 1;
  }
  res += calc(s, getlen(s));
  return res;
}
void work() { cout << calc2(R) - calc2(L - 1) << endl; }
int main() {
  init();
  work();
  return 0;
}
