#include <bits/stdc++.h>
using namespace std;
const int N = 70 + 5;
int a[N], b[N], q[N];
long long L, R;
bool prime[N];
void init() {
  int p[18] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
               29, 31, 37, 41, 43, 47, 53, 59, 61};
  memset(prime, 0, sizeof(prime));
  for (int i = 0; i < 18; i++) prime[p[i]] = 1;
}
void getBit(long long n, int q[]) {
  q[0] = 0;
  while (n) {
    q[++q[0]] = n & 1;
    n >>= 1;
  }
}
void getFreq(int x) {
  q[0] = 0;
  for (int i = 2; i < x; i++)
    if (!(x % i) && prime[i]) {
      q[++q[0]] = i;
    }
}
long long highNum(int q[], int len) {
  long long ans = 0;
  for (int i = 0; i < len; i++) {
    ans <<= 1;
    ans |= q[q[0] - i];
  }
  return ans;
}
bool check(long long num, int T, int len) {
  long long ans = 0;
  while (T--) {
    ans <<= len;
    ans |= num;
  }
  return L <= ans && ans <= R;
}
long long cal(int n, int len) {
  long long high, low;
  long long ans = 0;
  if ((n == a[0]) && (n == b[0])) {
    low = highNum(a, len);
    high = highNum(b, len);
    if (high == low)
      ans += check(high, n / len, len);
    else {
      ans += check(high, n / len, len);
      ans += check(low, n / len, len);
      ans += high - low - 1;
    }
  } else if (n == b[0]) {
    high = highNum(b, len);
    ans += check(high, n / len, len);
    high ^= 1LL << (len - 1);
    ans += high;
  } else if (n == a[0]) {
    low = highNum(a, len);
    ans += check(low, n / len, len);
    low ^= 1LL << (len - 1);
    ans += ((1LL << (len - 1)) - 1) - low;
  } else
    ans += 1LL << (len - 1);
  return ans;
}
long long sovle(int n) {
  long long ans = 0;
  if (n == 1) return ans;
  getFreq(n);
  if (!q[0]) q[++q[0]] = n;
  for (int i = 1; i <= q[0]; i++) {
    ans += cal(n, n / q[i]);
    for (int j = i + 1; j <= q[0]; j++) {
      ans -= cal(n, n / q[i] / q[j]);
      for (int k = j + 1; k <= q[0]; k++) {
        ans += cal(n, n / q[i] / q[j] / q[k]);
      }
    }
  }
  return ans;
}
int main() {
  long long ans;
  init();
  while (cin >> L >> R) {
    getBit(L, a);
    getBit(R, b);
    ans = 0;
    for (int i = a[0]; i <= b[0]; i++) ans += sovle(i);
    cout << ans << endl;
  }
  return 0;
}
