#include <bits/stdc++.h>
using namespace std;
long long count(long long Max, long long length) {
  vector<long long> sol(length + 1, 0ll);
  long long ret = 0;
  for (int seg = 1; seg < length; seg++) {
    if (length % seg != 0) continue;
    long long l = (1ll << (seg - 1)), r = (1ll << seg) - 1, t = -1, mid;
    int numSeg = length / seg;
    while (l <= r) {
      mid = (l + r) / 2ll;
      long long temp = 0ll;
      for (int i = 0; i < numSeg; i++) {
        temp <<= 1ll * seg;
        temp += mid;
      }
      if (temp <= Max) {
        t = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    if (t == -1) continue;
    long long legal = t + 1ll;
    legal -= (1 << (seg - 1));
    for (int i = 1; i < seg; i++) {
      if (seg % i != 0) continue;
      legal -= sol[i];
    }
    sol[seg] = legal;
    ret += legal;
  }
  return ret;
}
long long solve(long long Max) {
  if (Max <= 1) return 0;
  int length = 0;
  long long temp = Max;
  while (temp) {
    length += 1;
    temp /= 2ll;
  }
  long long ret = 0;
  for (int i = 2; i <= length; i++) {
    if (i == length) {
      ret += count(Max, length);
    } else {
      ret += count((1ll << (i)) - 1, i);
    }
  }
  return ret;
}
int main() {
  long long l, r;
  cin >> l >> r;
  long long a = solve(l - 1), b = solve(r);
  cout << b - a << endl;
  return 0;
}
