#include <bits/stdc++.h>
using namespace std;
int iec[100];
int lg(long long no) {
  int ret = 0;
  while (no > 0) ret++, no /= 2;
  return ret;
}
long long solve(long long no) {
  long long ans = 0, high, low, gen;
  int K = lg(no);
  for (int base = 1; base < K; base++) {
    for (int power = 2; power * base <= K; power++) {
      low = 1LL << (base - 1);
      gen = 0;
      for (int i = 0; i < power; i++) gen += (1LL << i * base);
      if (power * base == K)
        high = no / gen;
      else
        high = (1LL << base) - 1;
      ans += (high - low + 1) * -iec[power];
    }
  }
  return ans;
}
int main() {
  iec[1] = 1;
  for (int i = 1; i < 100; i++) {
    for (int j = 2; i * j < 100; j++) {
      iec[i * j] -= iec[i];
    }
  }
  long long l, r;
  cin >> l >> r;
  cout << solve(r) - solve(l - 1) << endl;
  return 0;
}
