#include <bits/stdc++.h>
using namespace std;
const long long N = 61, I = 1LL;
long long A[N], x, y;
long long get(long long r) {
  if (!r) return (0);
  long long rt = 0LL;
  for (long long ln = I; ln < N; ln++) {
    for (long long seg = 2LL; seg * ln < N; seg++) {
      long long tv = 0LL;
      for (long long k = 0LL; k < seg; k++) tv += I << (ln * k);
      long long L = I << (ln - 1LL);
      long long R = min(r / tv, (I << ln) - I);
      if (L <= R) rt += (R - L + I) * A[seg];
    }
  }
  return (rt);
}
int32_t main() {
  scanf("%I64d %I64d", &x, &y);
  fill(A, A + N, 1);
  for (long long i = 2; i < N; i++)
    for (long long j = i + i; j < N; j += i) A[j] -= A[i];
  printf("%I64d", get(y) - get(x - I));
}
