#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const long long INF = (long long)1e16;
long long dp[61][61], takeFull[61];
void process() {
  for (int i = 1; i <= 60; ++i) {
    for (int j = 1; j < i; ++j) {
      if (i % j == 0) {
        dp[i][j] = (1 << (j - 1));
        for (int k = 1; k < j; ++k) {
          if (j % k == 0) dp[i][j] -= dp[i][k];
        }
      }
      takeFull[i] += dp[i][j];
    }
  }
}
long long fullUtilize(int len) { return takeFull[len]; }
int getMSB(long long a) {
  for (int i = 60; i >= 0; --i) {
    if ((a >> i) & 1) return i;
  }
}
string getBitString(long long a) {
  string res = (bitset<61>(a)).to_string();
  for (int i = 0; i < res.size(); ++i) {
    if (res[i] == '1') return res.substr(i);
  }
}
long long getFullUtilization(int sigBit) {
  long long res = 0;
  for (int i = 1; i <= sigBit; ++i) {
    res += fullUtilize(i);
  }
  return res;
}
string getBestMatch(string s, int n) {
  string res = "";
  while (n--) {
    res += s;
  }
  return res;
}
long long getVal(string s) { return (bitset<60>(s)).to_ullong(); }
long long getSuffVal(string s) {
  if (s.size() == 1) return 0;
  return getVal(s.substr(1));
}
string getExtreme(string s, int p) {
  string t = "";
  while (t.size() < s.size()) {
    t += s.substr(0, p);
  }
  return t;
}
long long solve(long long a) {
  if (a == 0) return 0;
  int MSB = getMSB(a);
  long long res = getFullUtilization(getMSB(a));
  string bitString = getBitString(a);
  int n = bitString.size();
  long long sol[61];
  memset(sol, 0, sizeof sol);
  for (int i = 1; i < n; ++i) {
    if (n % i == 0) {
      sol[i] = getSuffVal(bitString.substr(0, i));
      string xtreme = getExtreme(bitString, i);
      if (getVal(xtreme) <= a) ++sol[i];
      for (int j = 1; j < i; ++j) {
        if (i % j == 0) sol[i] -= sol[j];
      }
    }
    res += sol[i];
  }
  return res;
}
int main() {
  process();
  long long a, b;
  cin >> a >> b;
  cout << (solve(b) - solve(a - 1));
  return 0;
}
