import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // ================================================================== public void solve() { int A = Integer.parseInt(sc.next()); int B = Integer.parseInt(sc.next()); if(A > B) { out.println(0); return; } char[] ca = Integer.toBinaryString(A).toCharArray(); char[] cb = Integer.toBinaryString(B).toCharArray(); int offset = cb.length - ca.length; if(ca[0] != cb[offset]) { out.println(0); return; } int cnt = 1, flg = 0; if(offset > 0) flg = 1; for (int i = 1; i < ca.length; i++) { if(ca[i] == 1 && cb[i+offset] == 0) { out.println(0); return; } if(flg == 0 && ca[i] != cb[i+offset]) { flg = 1; } else if(ca[i] != cb[i+offset]) { cnt *= 2; } } out.println(cnt); } // ================================================================== }