#include <bits/stdc++.h>
using namespace std;
long long get(long long a) {
  long long res = 0;
  for (int i = 1; i < 62; i++) {
    for (int j = 1; j < i; j++) {
      if (i % j == 0) {
        long long form = 0;
        for (int k = 0; k < i; k += j) {
          form += (1LL << k);
        }
        long long lo = min(a / form, (1LL << j) - 1);
        long long cnt = lo - (1LL << (j - 1)) + 1;
        if (cnt <= 0) continue;
        int t = i / j;
        int mult = 1;
        bool flag = 1;
        for (int k = 2; k * k <= t; k++) {
          if (t % k == 0) {
            t /= k;
            mult = -mult;
          }
          if (t % k == 0) {
            flag = false;
            break;
          }
        }
        if (!flag) continue;
        res += cnt * mult;
      }
    }
  }
  return res;
}
int main() {
  long long a, b;
  cin >> a >> b;
  cout << get(b) - get(a - 1);
}
