#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
long long l, r;
long long two[64];
long long g[64];
long long calculate2(int num, long long end) {
  long long i, j;
  long long begin;
  long long temp = 0, x;
  long long from, to, mid;
  begin = two[num - 1];
  if (begin >= end) {
    return 0;
  }
  memset(g, -1, sizeof(long long) * 64);
  for (i = 1; i <= num / 2; i++) {
    if (num % i == 0) {
      from = two[i - 1];
      to = two[i] - 1;
      while (from != to) {
        mid = (from + to + 1) / 2;
        x = mid;
        for (j = 1; j <= num / i - 1; j++) {
          x = x * (two[i]) + mid;
        }
        if (x <= end) {
          from = mid;
        } else {
          to = mid - 1;
        }
      }
      x = from;
      for (j = 1; j <= num / i - 1; j++) {
        x = x * (two[i]) + from;
      }
      if (x <= end) {
        g[i] = from - two[i - 1] + 1;
      } else {
        g[i] = 0;
      }
    }
  }
  for (i = 2; i <= num / 2; i++) {
    if (g[i] != -1) {
      for (j = 1; j <= i / 2; j++) {
        if (i % j == 0) {
          g[i] -= g[j];
        }
      }
    }
  }
  for (i = 1; i <= num / 2; i++) {
    if (num % i == 0) {
      temp += g[i];
    }
  }
  return temp;
}
long long calculate1(int num) {
  long long i, j;
  long long temp = 0;
  for (i = 1; i <= num / 2; i++) {
    if (num % i == 0) {
      temp += g[i];
    }
  }
  return temp;
}
int main() {
  long long i, j, k;
  long long from = 0, to = 0;
  long long ll, rr;
  cin >> l >> r;
  two[0] = 1;
  for (i = 1; i <= 63; i++) {
    two[i] = two[i - 1] * 2;
  }
  ll = l;
  rr = r;
  while (ll != 0) {
    ll /= 2;
    from++;
  }
  while (rr != 0) {
    rr /= 2;
    to++;
  }
  to--;
  for (i = 1; i <= 33; i++) {
    g[i] = two[i - 1];
  }
  for (i = 2; i <= 33; i++) {
    for (j = 1; j <= i / 2; j++) {
      if (i % j == 0) {
        g[i] -= g[j];
      }
    }
  }
  for (i = from; i <= to; i++) {
    ans += calculate1(i);
  }
  ans -= calculate2(from, l - 1);
  ans += calculate2(to + 1, r);
  cout << ans << endl;
  return 0;
}
