#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100;
long long dp[maxn];
long long g[maxn];
long long t[maxn];
vector<long long> binary(long long y) {
  vector<long long> q;
  while (y > 0) {
    q.push_back(y % 2);
    y /= 2;
  }
  reverse(q.begin(), q.end());
  return q;
}
long long f(long long x) {
  long long ret = 0;
  vector<long long> b;
  b = binary(x);
  for (long long i = 1; i < b.size(); i++) {
    if (b[i] == 1) {
      for (long long d = 1; d < b.size(); d++) {
        if (b.size() % d == 0) {
          dp[d] = 1;
          for (long long j = 0; j < i; j++) {
            if (j >= d && b[j] != b[j - d]) {
              dp[d] = 0;
            }
          }
          if (i >= d && b[i - d] != 0) {
            dp[d] = 0;
          }
          if (dp[d] == 0) continue;
          dp[d] = t[max((d - i - 1), 0ll)];
          for (long long z = 1; z < d; z++) {
            if (d % z == 0) {
              dp[d] -= dp[z];
            }
          }
          ret += dp[d];
        }
      }
    }
  }
  for (long long l = 1; l < b.size(); l++) {
    ret += g[l];
  }
  return ret;
}
int32_t main() {
  t[0] = 1;
  for (long long i = 1; i < maxn; i++) {
    t[i] = t[i - 1] * 2;
  }
  for (long long i = 1; i < maxn; i++) {
    for (long long j = 1; j < i; j++) {
      if (i % j == 0) {
        g[i] += t[j - 1] - g[j];
      }
    }
  }
  long long l, r;
  cin >> l >> r;
  cout << f(r + 1) - f(l) << endl;
}
