#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long l, r, nums[100], numm[100];
string a;
string con(long long x) {
  string ans;
  while (x) {
    ans.push_back('0' + (x % 2));
    x /= 2;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long pw(long long x, long long y) {
  if (y == 0) return 1;
  long long ans = pw(x, y / 2);
  ans = ans * ans;
  if (y % 2) ans = ans * x;
  return ans;
}
long long GetFirst(long long y) {
  long long l = 0, r = pw(2, y - 1) - 1, mid;
  while (l < r) {
    mid = (l + r) / 2;
    string b = con((1ll << y - 1) + mid), c;
    while (c.size() != a.size()) c += b;
    if (c <= a)
      l = mid + 1;
    else
      r = mid;
  }
  return l;
}
long long NiggasInParis(long long x) {
  memset(nums, 0, sizeof nums);
  memset(numm, 0, sizeof numm);
  a = con(x);
  long long ans = 0;
  for (int i = 2; i < a.size(); i++) {
    long long num = pw(2, i - 1) - 1;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) num -= nums[j];
    }
    int f = 0;
    if (a.size() % i == 0) f = 1;
    nums[i] = num;
    ans += num * (a.size() / i - 1 - f);
  }
  for (int i = 2; i < a.size(); i++) {
    if (a.size() % i) continue;
    long long c = GetFirst(i);
    for (int j = i - 1; j >= 2; j--) {
      if (i % j == 0) {
        c -= numm[j];
      }
    }
    numm[i] = c;
    ans += c;
  }
  for (int i = 2; i <= 64; i++) {
    if ((1ll << i) - 1 <= x)
      ans++;
    else
      break;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> l >> r;
  for (int i = 2; i <= 64; i++) {
    int f = 0;
    for (int j = 2; j <= sqrt(i); j++) {
      if (i % j == 0) f = 0;
    }
  }
  cout << NiggasInParis(r) - NiggasInParis(l - 1);
}
