#include <iostream>
using namespace std;
int CountNodes(int m, int n) {
if (m > n) {
return 0;
}
else {
return CountNodes(2 * m, n) + CountNodes(2 * m + 1, n) + 1;
}
}
int main()
{
int m, n;
while (cin >> m >> n) {
if (m == 0 && n == 0) {
break;
}
cout << CountNodes(m, n) << endl;
}
return 0;
}