#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
#pragma GCC target("avx,avx2")
using namespace std;
template <class t>
inline void read(t &s) {
  s = 0;
  register long long f = 1;
  register char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  s *= f;
  return;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
  return;
}
template <class t>
inline void write(t x) {
  if (x < 0) putchar('-'), x = -x;
  long long buf[21], top = 0;
  while (x) buf[++top] = x % 10, x /= 10;
  if (!top) buf[++top] = 0;
  while (top) putchar(buf[top--] ^ '0');
  return;
}
inline void setIn(string s) {
  freopen(s.c_str(), "r", stdin);
  return;
}
inline void setOut(string s) {
  freopen(s.c_str(), "w", stdout);
  return;
}
inline void setIO(string s = "") {
  setIn(s + ".in");
  setOut(s + ".out");
  return;
}
inline void checkmin(long long &x, long long y) {
  if (x > y) x = y;
  return;
}
inline void checkmax(long long &x, long long y) {
  if (x < y) x = y;
  return;
}
inline long long lowbit(long long x) { return x & (-x); }
long long a[70], t[70], f[70][70], Len, D;
long long Ans[70][70];
inline long long dfs(long long dep, long long zero, bool lim) {
  if (!dep) return zero == Len;
  if (!lim && ~f[dep][zero]) return f[dep][zero];
  register long long maxi = lim ? a[dep] : 1, res = 0;
  for (long long i = 0; i <= maxi; ++i) {
    register long long nzero = zero;
    if (i && !nzero) nzero = dep;
    if (nzero - dep < D) {
      t[nzero - dep] = i;
      res += dfs(dep - 1, nzero, lim && (i == maxi));
    } else if (t[(nzero - dep) % D] == i)
      res += dfs(dep - 1, nzero, lim && (i == maxi));
  }
  if (!lim) f[dep][zero] = res;
  return res;
}
inline long long calc(long long x, long long l, long long d) {
  register long long cnt = 0;
  while (x) a[++cnt] = (x & 1), x >>= 1;
  memset(f, -1, sizeof f);
  Len = l;
  D = d;
  return dfs(cnt, 0, true);
}
signed main(void) {
  register long long l, r;
  read(l, r);
  for (long long i = 1; i <= 64; ++i)
    for (long long j = 1; j < i; ++j)
      if (!(i % j)) Ans[i][j] = calc(r, i, j) - calc(l - 1, i, j);
  for (long long i = 1; i <= 64; ++i)
    for (long long j = 1; j < i; ++j)
      if (!(i % j))
        for (long long k = 1; k < j; ++k)
          if (!(j % k)) Ans[i][j] -= Ans[i][k];
  register long long ans = 0;
  for (long long i = 1; i <= 64; ++i)
    for (long long j = 1; j < i; ++j) ans += Ans[i][j];
  write(ans), puts("");
  return 0;
}
