#include <bits/stdc++.h>
using namespace std;
const long long N = 67, OO = 1e8, M = 1e9 + 7, P = 6151, sq = 360, lg = 23;
vector<long long> p[N];
long long g[N][N], pw[N];
long long get(long long x) {
  if (x == 1) return 0;
  long long cnt = 0;
  for (auto u : p[x]) cnt += pw[u];
  return cnt + get(x - 1);
}
long long ans(long long x) {
  if (x <= 1) return 0;
  long long k = log2(x);
  vector<bool> v;
  long long cnt = get(k);
  long long hn = 0, y = x;
  while (x > 0) v.push_back(x % 2), hn += (x % 2), x /= 2;
  k++;
  reverse(v.begin(), v.end());
  for (long long i = 0; i < p[k].size(); i++) {
    long long t = p[k][i];
    g[k][t] = 0;
    for (long long j = 1; j < t; j++) {
      if (v[j] == 0) continue;
      g[k][t] += (1ll << (t - j - 1));
    }
    bool u = true;
    for (long long j = 0; j < k; j++) {
      if (v[j % t] < v[j]) break;
      if (v[j % t] == v[j]) continue;
      u = false;
      break;
    }
    g[k][t] += u;
    for (long long j = 0; j < i; j++) {
      long long z = p[k][j];
      if (t % z != 0) continue;
      g[k][t] -= g[k][z];
    }
    cnt += g[k][t];
  }
  return cnt;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long l, r;
  for (long long i = 1; i < 64; i++) {
    bool u = true;
    pw[i] = (1ll << (i - 1));
    for (long long j = 1; j < i; j++)
      if (i % j == 0) p[i].push_back(j), pw[i] -= pw[j];
  }
  cin >> l >> r;
  cout << ans(r) - ans(l - 1) << endl;
  return 0;
}
