#include <bits/stdc++.h>
using namespace std;
long long dig[65], cnt, pw[62], cur, f[65];
long long solve(long long k) {
  long long val = 0, ans = 0;
  for (long long i = 1; i < k + 2; i++) {
    if (i == k + 1) {
      if (val <= cur) ans++;
    } else {
      if (i > 1 && dig[i] == 1) {
        ans += pw[k - i];
      }
      if (dig[i] == 1) {
        long long pos = i;
        while (pos <= cnt) {
          val |= (1LL << (cnt - pos));
          pos += k;
        }
      }
    }
  }
  return ans;
}
long long calc(long long r) {
  long long ptr = 0;
  cur = r;
  while (r) {
    dig[++ptr] = r & 1;
    r >>= 1;
  }
  reverse(dig + 1, dig + ptr + 1);
  cnt = ptr;
  long long ans = 0;
  for (long long i = 2; i < cnt + 1; i++) {
    memset(f, 0, sizeof(f));
    for (long long j = 1; j < i; j++)
      if (i % j == 0) {
        if (i < cnt)
          f[j] = pw[j - 1];
        else
          f[j] = solve(j);
        for (long long k = 1; k < j; k++)
          if (j % k == 0) f[j] -= f[k];
        ans += f[j];
      }
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long l, r;
  cin >> l >> r;
  pw[0] = 1;
  for (long long i = 1; i < 62; i++) pw[i] = pw[i - 1] * 2;
  cout << calc(r) - calc(l - 1);
  return 0;
}
