#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void input(T &x) {
  register char c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline long long bigmod(long long p, long long e, long long M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
const int N = 1 << 20;
long long calc(long long n) {
  long long ans = 0;
  for (int len = 1; len <= 32; len++) {
    long long v = (1LL << len) + 1;
    long long x = n / v;
    if (x < (1LL << (len - 1))) continue;
    long long now = x + 1 - (1LL << (len - 1));
    now = min(now, 1LL << (len - 1));
    ans += now;
  }
  return ans;
}
int pw[N];
int dig(long long n) {
  for (int i = 62; i >= 0; i--) {
    if (n & (1LL << i)) return i + 1;
  }
  return -1;
}
bool isch(long long n) {
  long long w = dig(n);
  if (w % 2 == 0 && ((n >> (w / 2)) == (n % (1LL << (w / 2))))) return 1;
  return 0;
}
long long func(long long n) {
  if (n <= 2) return 0;
  long long ans = calc(n);
  unordered_map<long long, int> Map;
  for (long long i = 1; i < N; i++) {
    int k = pw[i];
    long long m = (1LL << k);
    long long c = i * m + i;
    if (c >= n) continue;
    for (; c <= (n - i) / m;) {
      c = c * m + i;
      if (c <= n && isch(c) == 0 && Map.count(c) == 0) {
        ans++;
        Map[c] = 1;
      }
    }
  }
  return ans;
}
int main() {
  int cnt = 0;
  for (int i = 1; i < N; i++) {
    if ((i & (i - 1)) == 0) cnt++;
    pw[i] = cnt;
  }
  long long l, r;
  cin >> l >> r;
  cout << func(r) - func(l - 1) << endl;
  return 0;
}
