#include <bits/stdc++.h>
using namespace std;
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
long long l, r, bit[75], dp[75];
long long cal(long long len, long long k, long long x) {
  long long a = 0, b = 0;
  for (long long i = 0; i < k; i++) a += (bit[len - i] << k - i - 1);
  b = a;
  for (long long i = 1; i < len / k; i++) b <<= k, b += a;
  return a - (1 << k - 1) + (b <= x);
}
long long DP(long long x) {
  long long len = 0, n = x, res = 0;
  while (x) bit[++len] = x & 1, x >>= 1;
  for (long long i = 2; i <= len; i++) {
    memset(dp, 0, sizeof(dp));
    for (long long j = 1; j < i; j++) {
      if (i % j != 0) continue;
      dp[j] = i < len ? 1 << j - 1 : cal(len, j, n);
      for (long long k = 1; k < j; k++)
        if (j % k == 0) dp[j] -= dp[k];
      res += dp[j];
    }
  }
  return res;
}
signed main() {
  read(l);
  read(r);
  printf("%lld\n", DP(r) - DP(l - 1));
  return 0;
}
