#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
long long mult(long long x, int period, int k) {
  long long res = 0;
  while (k--) {
    res = (res << (long long)period) + x;
  }
  return res;
}
long long get(long long gh) {
  if (gh == 0) return 0;
  if (gh == 1) return 0;
  int len = 0;
  long long u = gh;
  while (u) {
    ++len;
    u /= 2;
  }
  long long sum = 0;
  for (int period = (1), _b = (len - 1); period <= _b; period++)
    for (int k = (2), _b = (len); k <= _b; k++)
      if (k * period <= len) {
        long long l = 0, r = (1LL << (period)) - 1, res = 0;
        while (l <= r) {
          long long mid = (l + r) >> 1;
          if (mult(mid, period, k) <= gh) {
            res = mid;
            l = mid + 1;
          } else
            r = mid - 1;
        }
        long long add = res - get(res);
        if (period > 1) {
          if (res <= (1LL << (period - 1)) - 1) continue;
          add -= (1LL << (period - 1)) - 1;
          add += get((1LL << (period - 1)) - 1);
        }
        sum += add;
      }
  return sum;
}
int main() {
  long long l, r;
  while (cin >> l >> r) {
    cout << get(r) - get(l - 1) << endl;
  }
  return 0;
}
