#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void smn(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void smx(T &a, const T &b) {
  if (b > a) a = b;
}
template <class T>
inline T rev(const T &a) {
  T _ = a;
  reverse(_.begin(), _.end());
  return _;
}
const double eps = 1e-9;
const long double leps = 1e-14;
long long l, r;
long long res;
long long d[100];
int dv[100];
int dsu[100];
bool av[100];
int p;
int par(int a) { return dsu[a] == a ? a : dsu[a] = par(dsu[a]); }
void un(int a, int b) {
  a = par(a);
  b = par(b);
  if (a != b) {
    av[b] = 0;
    dsu[b] = a;
  }
}
long long calc(int a, int b, int mask) {
  for (int i = 0; i < a; i++) dsu[i] = i, av[i] = 1;
  for (int i = 0; i < p; i++)
    if ((((mask) >> (i)) & 1)) {
      int v = dv[i];
      for (int k = 0; k < v; k++)
        for (int k2 = k; k2 < a; k2 += v) un(k, k2);
    }
  for (int i = 0; i < b; i++)
    for (int j = 0; j < i; j++)
      if (d[i] != d[j] && par(i) == par(j)) return 0;
  for (int i = 0; i < b; i++) av[par(i)] = 0;
  int cnt = 0;
  for (int i = 0; i < a; i++)
    if (av[i]) cnt++;
  return (1LL << cnt);
}
long long cnt(int a, int b, long long mask) {
  for (int i = 0; i < b; i++) d[b - 1 - i] = bool(mask & (1LL << i));
  p = 0;
  for (int i = 1; i < a; i++)
    if (a % i == 0) dv[p++] = i;
  long long res = 0;
  for (int i = 1; i < (1 << p); i++)
    if (((__builtin_popcount(i))) % 2 == 1)
      res += calc(a, b, i);
    else
      res -= calc(a, b, i);
  return res;
}
long long cnt(long long a) {
  int bt = 0;
  long long at = a;
  while (at) bt++, at /= 2;
  long long res = 0;
  for (int i = 1; i < bt; i++) res += cnt(i, 1, 1);
  long long now = 1;
  for (int i = 1; i < bt; i++) {
    if (a & (1LL << (bt - 1 - i))) res += cnt(bt, i + 1, now * 2);
    now = now * 2 + bool(a & (1LL << (bt - 1 - i)));
  }
  res += cnt(bt, bt, a);
  return res;
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin >> l >> r;
  res = cnt(r);
  if (l != 1) res -= cnt(l - 1);
  cout << res << '\n';
  return 0;
}
