#include <iostream>
#include <cstdio>

using namespace std;

int countNode(int m, int n) {
    if (m > n) {
        /*
         * 递归出口
         * 因为一共就n个顶点,所以m>n时结束即可
         */
        return 0;
    } else {
        /*
         * 根节点+左子树的节点数+右子树的节点数
         */
        return 1 + countNode(2 * m, n) + countNode(2 * m + 1, n);
    }
}

/**
 * 二叉树--北京大学
 * @return
 */
int main() {
    int m;
    int n;
    while (cin >> m >> n) {
        cout << countNode(m, n) << endl;
    }

    return 0;
}