#include <bits/stdc++.h>
using namespace std;
long long same(int tmp[], int n);
long long diff(int tmp[], int n);
long long work(long long v) {
  if (v == 0) return 0;
  int num[100], c = 0;
  while (v) {
    num[c++] = v & 1;
    v >>= 1;
  }
  for (int i = 0; i < c / 2; ++i) swap(num[i], num[c - i - 1]);
  long long ans = 0;
  int tmp[100];
  memset(tmp, -1, sizeof(tmp));
  for (int i = 1; i < c; ++i) {
    ans += same(tmp, i);
  }
  tmp[0] = 1;
  for (int i = 1; i < c; ++i) {
    if (num[i]) {
      tmp[i] = 0;
      ans += same(tmp, c);
    }
    tmp[i] = num[i];
  }
  ans += same(tmp, c);
  return ans;
}
int main() {
  long long l, r;
  cin >> l >> r;
  cout << work(r) - work(l - 1) << endl;
  return 0;
}
long long same(int num[], int n) {
  long long ans = 0;
  if (n <= 1) return 0;
  for (int i = 1; i < n; ++i)
    if (n % i == 0) {
      bool all = 1;
      for (int k = 0; k < i; ++k)
        if (num[k] == -1) all = 0;
      if (all) {
        bool flag = 1;
        for (int k = i; k < n; k += i) {
          for (int j = k; j < k + i; ++j)
            if (num[j] != -1 && num[j] != num[j - k]) flag = 0;
        }
        if (!flag) continue;
      }
      ans += diff(num, i);
    }
  return ans;
}
long long diff(int num[], int n) {
  long long ans = 1;
  for (int i = 1; i < n; ++i)
    if (num[i] == -1) ans *= 2;
  return ans - same(num, n);
}
