#include <bits/stdc++.h>
using namespace std;
long long doit(long long first) {
  long long ret = 0LL;
  for (int len = (1); len <= (int)(60); len++) {
    long long dp[len + 1];
    memset(dp, 0, sizeof(dp));
    for (int n = (1); n < (int)(len); n++)
      if (len % n == 0) {
        long long div = 0;
        for (int j = (0); j < (int)(len / n); j++) div = (div << n) | 1LL;
        long long hi = min(first / div, (1LL << n) - 1);
        long long lo = (1LL << n - 1);
        dp[n] = (hi >= lo ? (hi - lo + 1) : 0LL);
      }
    for (int n = (1); n < (int)(len); n++)
      if (len % n == 0) {
        for (int n2 = n + n; n2 <= len; n2 += n) {
          dp[n2] -= dp[n];
        }
        ret += dp[n];
      }
  }
  return ret;
}
int main() {
  long long L, R;
  while (cin >> L >> R) {
    long long ans = doit(R) - doit(L - 1);
    cout << ans << endl;
  }
  return 0;
}
