#include <bits/stdc++.h>
using namespace std;
long long dp[70];
long long c[70][70];
int num[70], pos[70];
int get(long long x) {
  int tot = 0;
  if (!x) num[tot++] = x;
  while (x) {
    num[tot++] = x % 2;
    x /= 2;
  }
  return tot;
}
long long dfs(int cur, int start, int len, bool bound) {
  if (cur == -1) return 1;
  long long ans = dp[cur];
  if (!bound && ~ans) return ans;
  int up = bound ? num[cur] : 1;
  ans = 0;
  for (int i = cur == start; i <= up; i++) {
    pos[start - cur] = i;
    if (start - cur < len || pos[(start - cur) % len] == i)
      ans += dfs(cur - 1, start, len, bound && i == up);
  }
  return bound ? ans : dp[cur] = ans;
}
long long cal(long long x) {
  memset(c, 0, sizeof c);
  int tot = get(x);
  for (int i = 1; i < tot; i++)
    for (int j = 2 * i; j <= tot; j += i) {
      memset(dp, -1, sizeof dp);
      c[j][i] = dfs(j - 1, j - 1, i, j == tot);
    }
  vector<int> dv[70];
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j < i; j++)
      if (i % j == 0) dv[i].push_back(j);
  long long ans = 0;
  for (int i = 1; i <= tot; i++) {
    for (int j = 1; j < dv[i].size(); j++) {
      for (int k = j - 1; k >= 0; k--)
        if (dv[i][j] % dv[i][k] == 0) c[i][dv[i][j]] -= c[i][dv[i][k]];
    }
    for (int j = 0; j < dv[i].size(); j++) ans += c[i][dv[i][j]];
  }
  return ans;
}
int main() {
  cal(97);
  long long a, b;
  cin >> a >> b;
  cout << cal(b) - cal(a - 1) << endl;
  return 0;
}
