#include <bits/stdc++.h>
using namespace std;
long long num[65], dp[65];
void pre_work() {
  num[1] = 0;
  for (long long x = 2; x <= 61; ++x) {
    for (long long i = 1; i < x; ++i)
      if (x % i == 0) {
        dp[i] = (1ll << (i - 1));
        for (long long j = 1; j < i; ++j)
          if (i % j == 0) dp[i] -= dp[j];
        num[x] += dp[i];
      }
  }
}
long long solve(long long x) {
  long long res = 0, len = 1;
  for (; len <= 61 && x > (1ll << len) - 1; ++len) res += num[len];
  for (long long i = 1; i < len; ++i)
    if (len % i == 0) {
      long long tmp = x, the_min = (1ll << i) - 1ll;
      while (tmp) {
        the_min = tmp & ((1ll << i) - 1ll);
        tmp >>= i;
      }
      tmp = 0;
      for (int j = 0; j < len / i; ++j) {
        tmp <<= i;
        tmp |= the_min;
      }
      if (tmp > x) --the_min;
      dp[i] = the_min - (1ll << (i - 1)) + 1;
      for (long long j = 1; j < i; ++j)
        if (i % j == 0) dp[i] -= dp[j];
      dp[i] = max(dp[i], 0ll);
      res += dp[i];
    }
  return res;
}
int main() {
  pre_work();
  long long l, r;
  scanf("%lld%lld", &l, &r);
  printf("%lld\n", solve(r) - solve(l - 1));
  return 0;
}
