import java.io.*;
import java.util.*;

public class bits_vd_g2 {

	static final int bits = 29;

	static int[] biggest = new int[bits];
	static {
		Arrays.fill(biggest, 1);
	}

	HashMap<String, Long> map = new HashMap<>();

	int[] getBitNumber(int l) {
		int[] res = new int[bits];
		for (int i = 0; i < bits; i++) {
			res[i] = l % 2;
			l /= 2;
		}
		return res;
	}

	long calc(int num, int[] g1, int[] g2, int[] g3) {
		if (num == 0) {
			return 1;
		}
		String index = num + " " + Arrays.toString(g1) + " "
				+ Arrays.toString(g2) + " " + Arrays.toString(g3);
		if (map.containsKey(index)) {
			return map.get(index);
		}
		long ans = 0;
		for (int first = 0; first <= 1; first++) {
			for (int second = 0; second <= 1; second++) {
				int third = (first | second) ^ second;
				if (first <= g1[num - 1] && second <= g2[num - 1]
						&& third <= g3[num - 1]) {
					ans += calc(num - 1, (first != g1[num - 1]) ? biggest : g1,
							(second != g2[num - 1]) ? biggest : g2,
							(third != g3[num - 1]) ? biggest : g3);
				}
			}
		}
		map.put(index, ans);
		return ans;
	}

	public long solve(int l, int r) throws IOException {
		if (r > 5000) {
			throw new AssertionError(); 
		}
		l--;
		int[][] borders = new int[2][0];
		borders[0] = getBitNumber(l);
		borders[1] = getBitNumber(r);
		long ans = 0;
		for (int i = 0; i < 8; i++) {
			long sign = Integer.bitCount(i) % 2 == 1 ? 1 : -1;
			ans += sign
					* calc(bits, borders[i % 2], borders[i / 2 % 2],
							borders[i / 4 % 2]);
		}
		return ans;
	}

	final String fileName = "bits_vd_".split("_")[0];

	public void run() throws IOException {
		br = new BufferedReader(new FileReader(fileName + ".in"));
		out = new PrintWriter(fileName + ".out");
		out.println(solve(nextInt(), nextInt()));
		out.close();
		br.close();
	}

	public static void main(String[] args) throws IOException {
		new bits_vd_g2().run();
	}

	BufferedReader br;
	StringTokenizer str;
	PrintWriter out;

	String next() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			str = new StringTokenizer(br.readLine());
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

}