#include <bits/stdc++.h>
using namespace std;
long long dp[100], dv[100];
long long calc(int n, int k, long long x) {
  bool smaller = false;
  for (int i = n - 1; i >= 0; i--) {
    int modbit = n - 1 - (n - 1 - i) % k;
    if (((x >> modbit) & 1) > ((x >> i) & 1)) {
      smaller = true;
      break;
    } else if (((x >> modbit) & 1) < ((x >> i) & 1))
      break;
  }
  long long num = x >> (n - k);
  if (smaller) num--;
  return num - (1LL << (k - 1)) + 1LL;
}
long long solve(long long num) {
  long long ans = 0;
  for (int i = 0; 1LL << i <= num; i++) {
    int n = i + 1;
    int cnt = 0;
    for (int j = 1; j < n; j++)
      if (n % j == 0) {
        dv[cnt] = j;
        dp[cnt] = calc(n, j, min((1LL << (i + 1)) - 1, num));
        cnt++;
      }
    for (int j = 0; j <= cnt; j++)
      for (int k = j + 1; k < cnt; k++)
        if (dv[k] % dv[j] == 0) dp[k] -= dp[j];
    for (int j = 0; j < cnt; j++) {
      ans += dp[j];
    }
  }
  return ans;
}
int main() {
  long long l, r;
  cin >> l >> r;
  cout << solve(r) - solve(l - 1) << "\n";
}
