#include <bits/stdc++.h>
using namespace std;
long long dp_len[70];
vector<long long> divi[72];
void pre() {
  for (long long i = 1; i <= 70; i++) {
    for (long long j = i * 2; j <= 70; j += i) {
      divi[j].push_back(i);
    }
  }
}
long long cnt[70];
long long solve_len(long long len) {
  long long ans = 0;
  memset((cnt), (0), sizeof(cnt));
  for (long long i = 0; i < divi[len].size(); i++) {
    long long u = divi[len][i];
    ans += (1LL << (u - 1));
    cnt[u] += (1LL << (u - 1));
    for (long long j = 0; j < divi[u].size(); j++) {
      long long v = divi[u][j];
      ans -= cnt[v];
      cnt[u] -= cnt[v];
    }
  }
  return ans;
}
long long cnt2[70];
long long solve(long long val) {
  vector<long long> dig;
  long long val2 = val;
  while (val2 > 0) {
    dig.push_back(val2 % 2);
    val2 /= 2;
  }
  reverse(dig.begin(), dig.end());
  long long ans = 0;
  for (long long i = 1; i < dig.size(); i++) ans += solve_len(i);
  memset((cnt2), (0), sizeof(cnt2));
  long long len = (long long)dig.size();
  string s1, s2;
  for (long long i = 0; i < divi[len].size(); i++) {
    long long u = divi[len][i];
    s1.clear();
    s2.clear();
    for (long long j = 0; j < u; j++) s1.push_back(dig[j] + '0');
    for (long long j = 1; j <= (len / u); j++) s2 += s1;
    long long sum = 0;
    reverse(s2.begin(), s2.end());
    for (long long j = 0; j < s2.size(); j++)
      sum = sum + ((s2[j] - '0') * (1LL << j));
    if (sum <= val) cnt2[u]++;
    for (long long j = 1; j < u; j++) {
      if (dig[j] == 1) {
        cnt2[u] += (1LL << (u - (j + 1)));
      }
    }
    for (long long j = 0; j < divi[u].size(); j++) {
      long long v = divi[u][j];
      cnt2[u] -= cnt2[v];
    }
    ans += cnt2[u];
  }
  return ans;
}
int main() {
  pre();
  long long l, r;
  scanf("%lld", &l);
  scanf("%lld", &r);
  if (l == 1) {
    printf("%d\n", solve(r));
  } else {
    printf("%d\n", solve(r) - solve(l - 1));
  }
  return 0;
}
