#include <bits/stdc++.h>
using namespace std;
long long x, y, d[100 + 5];
void Process();
int main() {
  Process();
  return 0;
}
long long Make(long long x, long long p, long long q) {
  long long k = 0ll;
  for (long long i = 1; i <= q; ++i) k = (k << p) + x;
  return k;
}
long long Check(long long p, long long q, long long k) {
  if (Make(1ll << (p - 1ll), p, q) > k) return 0ll;
  long long x = 1ll << (p - 1ll), y = (1ll << p), mid;
  while (x + 1ll != y) {
    mid = (x + y) / 2ll;
    if (Make(mid, p, q) <= k)
      x = mid;
    else
      y = mid;
  }
  return x - (1ll << (p - 1ll)) + 1ll;
}
long long Cal(long long k) {
  long long S = 0ll;
  for (long long i = 1; i <= 60; ++i) {
    memset(d, 0, sizeof(d));
    for (long long j = 1; j < i; ++j)
      if (i % j == 0) {
        d[j] = Check(j, i / j, k);
        for (int l = 1; l < j; ++l)
          if (j % l == 0) d[j] -= d[l];
        S += d[j];
      }
  }
  return S;
}
void Process() {
  cin >> x >> y;
  cout << Cal(y) - Cal(x - 1ll) << endl;
}
