#include <bits/stdc++.h>
using namespace std;
const int MAXN = 65;
long long full[MAXN] = {0};
int toBinary(long long n, bool s[]) {
  int len = 0;
  while (n) s[len++] = n % 2, n /= 2;
  for (int i = 0, j = len - 1; i < j; ++i, --j) swap(s[i], s[j]);
  return len;
}
long long toNum(bool s[], int r) {
  long long tmp = 0;
  for (int i = 0; i < r; ++i) tmp = tmp * 2 + s[i];
  return tmp;
}
bool check(unsigned long long start, int len, int rep,
           unsigned long long maxNum) {
  unsigned long long fin = 0;
  for (int i = 0; i < rep; ++i) fin = fin << len | start;
  return fin <= maxNum;
}
long long countPerNum(long long r) {
  if (r == 0) return 0;
  long long cnt = 0;
  long long sum[MAXN] = {0};
  bool str[MAXN];
  int len = toBinary(r, str);
  for (int i = 1; i < len; ++i)
    if (len % i == 0) {
      long long prev = toNum(str, i);
      sum[i] += prev - (1 << (i - 1)) + check(prev, i, len / i, r);
      cnt += sum[i];
      for (int j = i + i; j < len; j += i) sum[j] -= sum[i];
    }
  return cnt + full[len - 1];
}
int main() {
  full[1] = 0;
  for (int i = 2; i < MAXN; ++i) {
    for (int j = 1; j < i; ++j) {
      if (i % j == 0) full[i] += (1 << (j - 1));
    }
    for (int j = i + i; j < MAXN; j += i) full[j] -= full[i];
    full[i] += full[i - 1];
  }
  long long l, r;
  while (cin >> l >> r) {
    cout << countPerNum(r) - countPerNum(l - 1) << "\n";
  }
  return 0;
}
