#include <bits/stdc++.h>
using namespace std;
long long int eleva[100];
int fijado[100];
long long int cuantos[100];
long long int calcula(int n, int numfijados) {
  if (n == 1 or n < numfijados) return 0;
  calcula(n - 1, numfijados);
  long long int &c = cuantos[n];
  c = 0;
  for (int i = 1; i < n; i++) {
    if (n % i == 0) {
      if (i >= numfijados) {
        c += eleva[i - numfijados] - cuantos[i];
      } else {
        bool error = false;
        for (int j = i + 1; j <= numfijados and not error; j++)
          error = fijado[j] != fijado[j - i];
        if (not error) c++;
      }
    }
  }
  return c;
}
int bit[100];
long long int menores(long long int x) {
  if (x <= 1) return 0;
  int nbits = 0;
  while (x > 0) {
    nbits++;
    bit[nbits] = x % 2;
    x /= 2;
  }
  for (int i = 1, j = nbits; i < j; i++, j--) swap(bit[i], bit[j]);
  long long int c = 0;
  fijado[1] = 1;
  for (int n = 1; n < nbits; n++) c += calcula(n, 1);
  for (int i = 2; i <= nbits; i++) {
    if (bit[i] == 1) {
      fijado[i] = 0;
      c += calcula(nbits, i);
    }
    fijado[i] = bit[i];
  }
  return c;
}
int main() {
  eleva[0] = 1;
  for (int i = 1; i < 100; i++) eleva[i] = 2 * eleva[i - 1];
  long long int l, r;
  cin >> l >> r;
  cout << menores(r + 1) - menores(l) << endl;
}
