#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const double PI = 4 * atan(1);
const int INF = (int)1E9 + 5;
const double EPS = 1E-11;
const long long MOD = (long long)1E9 + 7;
int ntest = 0, test = 0;
inline void init();
inline void run();
inline void stop() { ntest = test - 1; }
int main() {
  init();
  while (++test <= ntest) {
    run();
  }
  return 0;
}
template <class T>
T gcd(T a, T b) {
  while (b != 0) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
inline int gcd(vector<int> nums) {
  int ret = nums[0];
  for (int i = 1; i < ((int)(nums).size()); ++i) {
    ret = gcd(ret, nums[i]);
  }
  return ret;
}
long long fDig[65];
inline void init() {
  ntest = 1;
  for (typeof(65) i = 0; i < (65); i++) fDig[i] = 0;
  for (int i = 2; i <= 64; ++i) {
    vector<int> divisors;
    for (int k = 1; k < i; ++k) {
      if (i % k == 0) {
        divisors.push_back(k);
      }
    }
    for (long long mask = 1; mask <= (1 << ((int)(divisors).size())) - 1;
         ++mask) {
      vector<int> _tmp;
      for (int t = 0; t <= 15; ++t) {
        if (mask & (1 << t)) {
          _tmp.push_back(divisors[t]);
        }
      }
      long long ret = ((long long)1) << (gcd(_tmp) - 1);
      if (((int)(_tmp).size()) % 2 == 1)
        fDig[i] += ret;
      else
        fDig[i] -= ret;
    }
  }
}
inline long long getVal(long long n) {
  long long ret = 0;
  vector<int> divisors;
  long long f[70];
  int b[70];
  int total = 0;
  long long _n = n;
  do {
    b[total++] = (_n % 2);
    _n >>= 1;
  } while (_n != 0);
  for (int i = 1; i < total; ++i) {
    ret += fDig[i];
  }
  for (int i = 1; i < total; ++i) {
    if (total % i == 0) {
      divisors.push_back(i);
      long long fi = 0;
      for (int j = total - 2; j >= total - i; --j) {
        fi = fi * 2 + b[j];
      }
      fi++;
      int t[70];
      for (int j = total - 1; j >= 0; --j) {
        t[j] = (j <= total - 1 - i) ? t[j + i] : b[j];
      }
      int cmp = 0;
      for (int j = total - 1; j >= 0; --j) {
        if (t[j] > b[j]) {
          cmp = -1;
          break;
        } else if (t[j] < b[j]) {
          cmp = 1;
          break;
        }
      }
      if (cmp == -1) fi--;
      f[i] = fi;
    }
  }
  for (long long mask = 1;
       mask <= ((long long)1 << ((int)(divisors).size())) - 1; ++mask) {
    vector<int> divs;
    for (int i = 0; i < 64; ++i) {
      if (mask & (((long long)1) << i)) {
        divs.push_back(divisors[i]);
      }
    }
    if (divs.size() % 2 == 1) {
      ret += f[gcd(divs)];
    } else
      ret -= f[gcd(divs)];
  }
  return ret;
}
inline void run() {
  long long l, r;
  cin >> l >> r;
  cout << getVal(r) - getVal(l - 1);
}
