#include <bits/stdc++.h>
using namespace std;
int getN(long long x) {
  int ret;
  for (ret = 0; (1ll << ret) <= x; ++ret)
    ;
  return ret;
}
long long dif(long long x, long long n) {
  if (x < (1ll << n - 1)) return 0;
  if (x == 1) return 1;
  long long ret = x - (1ll << n - 1) + 1;
  for (int i = 1; i < n; ++i) {
    if (n % i == 0) {
      long long fac = x >> (n - i);
      long long t = n / i - 1;
      long long tmp = fac;
      while (t--) tmp = (tmp << i) + fac;
      if (tmp <= x)
        ret -= dif(fac, i);
      else
        ret -= dif(fac - 1, i);
    }
  }
  return ret;
}
long long solve(long long x) {
  int n = getN(x);
  long long ret = 0;
  for (int i = 2; i < n; ++i) {
    for (int j = 1; j < i; ++j) {
      if (i % j == 0) ret += dif((1ll << j) - 1, j);
    }
  }
  for (int i = 1; i < n; ++i) {
    if (n % i == 0) {
      long long fac = x >> (n - i);
      long long t = n / i - 1;
      long long tmp = fac;
      while (t--) tmp = (tmp << i) + fac;
      if (tmp <= x)
        ret += dif(fac, i);
      else
        ret += dif(fac - 1, i);
    }
  }
  return ret;
}
int main() {
  long long l, r;
  while (cin >> l >> r) {
    cout << (solve(r) - solve(l - 1)) << endl;
  }
  return 0;
}
