#include <bits/stdc++.h>
using namespace std;
long long l, r;
int f[70];
long long calc(long long x) {
  if (x == 0) return 0;
  int i, j, k, len;
  memset(f, 0, sizeof(f));
  long long tmp = x;
  for (len = 0; tmp; tmp >>= 1, len++)
    ;
  long long res = 0;
  for (i = 2; i <= len; ++i) {
    int w = 1 - f[i];
    for (j = i; j <= len; j += i) f[j] += w;
    for (j = 1; j <= len; ++j) {
      long long hmr = 1LL << (j - 1);
      long long t = 1;
      for (k = 1; k < i; ++k) t = (t << j) + 1;
      long long mdk = min((1LL << j) - 1, x / t);
      if (hmr <= mdk) res += (mdk - hmr + 1) * w;
    }
  }
  return res;
}
int main() {
  cin >> l >> r;
  cout << calc(r) - calc(l - 1) << endl;
  return 0;
}
