#include <bits/stdc++.h>
using namespace std;
long long c[100][100];
long long get_base(int rep, int width) {
  long long t = 0;
  for (int i = 0; i < rep; i++) {
    t += (long long)1 << (width * i);
  }
  return t;
}
long long num(int rep, int width, long long lo, long long hi) {
  long long b = get_base(rep, width);
  if (b > hi) return 0;
  long long m = (long long)(1 << (width - 1));
  long long c1 = min(m, max((long long)0, hi / b - m + 1));
  long long c2 = min(m, max((long long)0, (lo - 1) / b - m + 1));
  return c1 - c2;
}
int coef(int rep) {
  int val = 1;
  for (int i = 2; i < rep; i++) {
    if (rep % i == 0) val -= coef(i);
  }
  return val;
}
int main() {
  long long l, r;
  long long total = 0;
  scanf("%I64d %I64d", &l, &r);
  for (int i = 2; i <= 60; i++) {
    for (int j = 1; i * j <= 60; j++) {
      c[i][j] = num(i, j, l, r);
      total += coef(i) * c[i][j];
    }
  }
  printf("%I64d\n", total);
}
