#include <bits/stdc++.h>
using namespace std;
long long dp[65];
long long get(long long n) {
  long long result = 0;
  for (long long c = 1; c <= 60; c++)
    for (long long r = 2; r * c <= 60; r++) {
      long long sum = 0;
      for (long long i = 0; i < r; i++) sum += (1LL << (i * c));
      long long high = min((1LL << c) - 1, n / sum);
      long long low = (1LL << (c - 1));
      if (high >= low) result += (high - low + 1) * (-dp[r]);
    }
  return result;
}
int main() {
  dp[1] = 1;
  for (long long i = 1; i <= 61; i++)
    for (long long j = 2 * i; j <= 61; j += i) dp[j] -= dp[i];
  long long l, r;
  cin >> l >> r;
  cout << get(r) - get(l - 1) << endl;
  return 0;
}
