#include <bits/stdc++.h>
using namespace std;
const long long MD = 1000000007;
const double PI = 3.1415926535;
const int MAX_INT = (int)1e9;
const long long MAX_LL = (long long)1e18;
long long l, r;
long long c[64];
void calc(long long x, long long& alen, long long& ans) {
  if (x <= 1) return;
  int len = 0;
  int b[64];
  while (x > 0) {
    b[len] = x % 2;
    len++;
    x /= 2;
  }
  for (int i = 0, j = len - 1; i < j; i++, j--) swap(b[i], b[j]);
  long long xx = 0;
  for (int i = 1; i < len; i++) {
    alen += ((1LL << (i - 1)) - c[i]);
    xx = xx * 2 + b[i - 1];
    if (len % i == 0) {
      for (int j = i; j < len; j++)
        if (b[j] > b[j % i]) {
          ans++;
          break;
        } else if (b[j] < b[j % i])
          break;
      long long a1 = 0, a2 = 0;
      calc(xx, a1, a2);
      ans += (xx - a2 - (1LL << (i - 1)));
    }
  }
}
long long calc2(long long x) {
  long long a1 = 0, a2 = 0;
  calc(x, a1, a2);
  return (a1 + a2);
}
int main() {
  c[1] = 1;
  for (int i = 2; i <= 63; i++) {
    c[i] = 1LL << (i - 1);
    for (int j = 1; j < i; j++)
      if (i % j == 0) c[i] -= c[j];
  }
  long long l, r;
  cin >> l >> r;
  cout << calc2(r + 1) - calc2(l) << endl;
  return 0;
}
