#include <bits/stdc++.h>
using namespace std;
long long l, r, ans;
long long sig[110];
long long cal(long long N) {
  long long ans = 0;
  for (int cir = 1; cir <= 60; cir++)
    for (int rep = 2; (cir * rep) <= 60; rep++) {
      long long sum = 0;
      for (int i = 0; i < rep; i++) sum += 1ll << (i * cir);
      long long p = 1ll << cir;
      long long high = min(p - 1, N / sum);
      long long low = p / 2;
      if (high >= low) ans += (high - low + 1) * -sig[rep];
    }
  return ans;
}
int main() {
  sig[1] = 1ll;
  for (int i = 1; i <= 100; i++)
    for (int j = i + i; j <= 100; j += i) sig[j] -= sig[i];
  cin >> l >> r;
  ans = cal(r) - cal(l - 1);
  cout << ans << endl;
}
