#include <bits/stdc++.h>
using namespace std;
bool check(long long mid, long long times, long long per, long long LIM) {
  long long num = 0;
  while (times--) {
    num = (num << per) + mid;
  }
  return num <= LIM;
}
long long solveEz(long long X, long long len, long long period) {
  long long lo = (1LL << (period - 1)), hi = (1LL << period) - 1;
  while (lo < hi) {
    long long mid = lo + (hi - lo) / 2;
    if (!check(mid, len / period, period, X)) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  if (!check(lo, len / period, period, X)) {
    return lo - (1LL << (period - 1));
  } else {
    return lo - (1LL << (period - 1)) + 1;
  }
}
long long solve(long long X) {
  long long fin = 0;
  for (int len = 1; (1LL << (len - 1)) < X; len++) {
    vector<long long> ans(len + 1, 0);
    for (int period = 1; period < len; period++) {
      if (len % period == 0) {
        ans[period] = solveEz(X, len, period);
      }
    }
    for (int period = 1; period < len; period++) {
      for (int i = 2 * period; i < len; i += period) {
        ans[i] -= ans[period];
      }
    }
    long long contrib = 0;
    for (int p = 1; p < len; p++) {
      if (len % p == 0) contrib += ans[p];
    }
    fin += contrib;
  }
  return fin;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long L, R;
  cin >> L >> R;
  cout << solve(R) - solve(L - 1);
  return 0;
}
