#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
long long a[100];
long long f[100];
long long dp[100];
long long l, r;
long long calc(long long i) {
  long long ret = 0;
  for (long long j = (1); j <= (i - 1); ++j) {
    if (i % j == 0) ret += f[j];
  }
  return ret;
}
long long solve(long long n) {
  long long tmp = n;
  long long top = 0;
  while (tmp) {
    a[++top] = tmp % 2;
    tmp /= 2;
  }
  if (top == 1) return 0;
  long long ret = 0;
  for (long long i = (1); i <= (top - 1); ++i) ret += calc(i);
  for (long long i = (1); i <= (top - 1); ++i)
    if (top % i == 0) {
      long long now = a[top];
      dp[i] = 0;
      for (long long j = (2); j <= (i); ++j) {
        if (a[top - j + 1]) dp[i] += 1 << (i - j);
        now = now * 2 + a[top - j + 1];
      }
      long long tmp = now;
      for (long long j = (2); j <= (top / i); ++j) tmp = (tmp << i) + now;
      if (tmp <= n) dp[i]++;
      for (long long j = (1); j <= (i - 1); ++j)
        if (i % j == 0) dp[i] -= dp[j];
      ret += dp[i];
    }
  return ret;
}
void cal(long long n) {
  f[1] = 1;
  for (long long i = (2); i <= (n); ++i) {
    f[i] = 1 << (i - 1);
    for (long long j = (1); j <= (i - 1); ++j)
      if (i % j == 0) f[i] -= f[j];
  }
}
int main() {
  cal(70);
  scanf("%I64d %I64d", &l, &r);
  printf("%I64d\n", solve(r) - solve(l - 1));
}
