#include <bits/stdc++.h>
using namespace std;
long long res[66];
long long div(long long l, long long r, long long t) {
  return r / t - (l - 1) / t;
}
long long get(long long l, long long r, long long len) {
  memset(res, 0, sizeof(res));
  for (long long i = 1; i < len; i++)
    if (len % i == 0) {
      long long tmp = 0;
      for (long long j = 0; j < len; j += i) tmp += (1LL << j);
      res[i] = div(l, r, tmp);
    }
  long long ans = 0;
  for (long long i = 1; i < len; i++)
    if (res[i]) {
      for (long long j = 1; j < i; j++)
        if (i % j == 0) res[i] -= res[j];
      ans += res[i];
    }
  return ans;
}
long long solve(long long n) {
  long long ans = 0;
  for (long long i = 2;; i++) {
    long long l = (1LL << (i - 1));
    long long r = (1LL << i) - 1;
    if (l > n) break;
    ans += get(l, min(r, n), i);
  }
  return ans;
}
int main() {
  long long l, r;
  while (~scanf("%I64d%I64d", &l, &r)) {
    printf("%I64d\n", solve(r) - solve(l - 1));
  }
  return 0;
}
