Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?


-----Input-----

The first line of the input contains two integers s and x (2 ≤ s ≤ 10^12, 0 ≤ x ≤ 10^12), the sum and bitwise xor of the pair of positive integers, respectively.


-----Output-----

Print a single integer, the number of solutions to the given conditions. If no solutions exist, print 0.


-----Examples-----
Input
9 5

Output
4

Input
3 3

Output
2

Input
5 2

Output
0



-----Note-----

In the first sample, we have the following solutions: (2, 7), (3, 6), (6, 3), (7, 2).

In the second sample, the only solutions are (1, 2) and (2, 1).

Difficulty: interview

Starter code:

Solutions:
s, x = list(map(int, input().split()))
rem = int(s == x) * 2
p, t, cur = [], 0, 1
for i in range(64):
    if x % 2:
        t += 1
        s -= cur
    else:
        p.append(cur * 2)
    cur *= 2
    x //= 2
for i in p[::-1]:
    if s >= i: s -= i
ans = 0 if s else 2 ** t - rem
print(ans)


def o(s,x):
    d=s-x
    if x<<1 & d or d%2 or d<0: return 0
    return 2**(bin(x).count('1'))-(0 if d else 2)
s,x=map(int,input().split())
print(o(s,x))

s, x = list(map(int, input().split(' ')))
if (s-x)%2 or s < x:
    print(0)
else:
    c = bin((s-x)//2)[2:][::-1]
    t = bin(x)[2:][::-1]
    for i in range(len(t)):
        if t[i] == '1' and i < len(c) and c[i] == '1':
            print(0)
            return
    print(pow(2, bin(x)[2:].count('1'))-(2 if s==x else 0))


def main():
    s, x = list(map(int, input().split()))
    if s < x:
        print(0)
        return
    s, x = ([c == '1' for c in bin(int(_))[2:]] for _ in (s, x))
    x = [False] * (len(s) - len(x)) + x
    a, b = [False] * len(s), [False] * len(s)

    def deeper(idx, carry):
        if idx:
            idx -= 1
            if carry:
                if s[idx] == x[idx]:
                    return
                if s[idx]:
                    deeper(idx, False)
                    a[idx] = True
                    b[idx] = True
                    deeper(idx, True)
                    a[idx] = False
                    b[idx] = False
                else:
                    b[idx] = True
                    deeper(idx, True)
                    b[idx] = False
            else:
                if s[idx] != x[idx]:
                    return
                if s[idx]:
                    b[idx] = True
                    deeper(idx, False)
                    b[idx] = False
                else:
                    a[idx] = True
                    b[idx] = True
                    deeper(idx, True)
                    a[idx] = False
                    b[idx] = False
                    deeper(idx, False)
        else:
            raise TabError

    try:
        deeper(len(s), False)
    except TabError:
        print((1 << (sum(b) - sum(a))) - (0 if any(a)else 2))
    else:
        print(0)


def __starting_point():
    main()

__starting_point()

'__author__'=='deepak Singh Mehta(learning brute force)) '


def __starting_point():
  s, x = list(map(int, input().split(' ')))
  if (s-x)%2 or s < x:
      print(0)
  else:
      c = bin((s-x)//2)[2:][::-1]
      t = bin(x)[2:][::-1]
      for i in range(len(t)):
          if t[i] == '1' and i < len(c) and c[i] == '1':
              print(0)
              return
      print(pow(2, bin(x)[2:].count('1'))-(2 if s==x else 0))

__starting_point()

'''
Created on Apr 20, 2016
Gmail : r.haque.249@gmail.com
@author: Md. Rezwanul Haque
'''
def func(s,x):
    if x==0 and s%2==0:
        return 1
    if s==0:
        return 0
    if (s%2==1 and x%2==1):
        return 2*func(s//2, x//2)
    if (s%2==1 and x%2==0):
        return 0
    if (s%2== 0 and x%2==1):
        return 0
    if s%2==0 and x%2==0:
        return func(s//2 - 1, x//2) + func(s//2, x//2)
    
s,x = list(map(int,input().split()))
cnt = func(s, x)
if s^0 == x:
    cnt = cnt - 2;
print(cnt)
    


def digits(n):
    d = []
    while n:
        d.append(n%2)
        n //= 2
    return d
s, x = map(int, input().split())
#for i in range(s+1):
#    if i^(s-i) == x:
#        print(i, s-i)
flag = True
if s-x < 0 or (s-x)%2 == 1:
    print(0)
else:
    a = (s-x) >> 1
    AND = digits(a)
    XOR = digits(x)
    for i in range(max(len(AND), len(XOR))):# comparing from reverse
        if i < len(XOR):
            xi = XOR[i]
        else:
            xi = 0
        if i < len(AND):
            ai = AND[i]
        else:
            ai = 0
        if xi == 1 and ai != 0:
            print(0)
            flag = False
            break
    if flag:
        data = XOR.count(1)
        ans = 2**data
        if a == 0:
            ans -= 2
        print(ans)

s, x = map(int, input().split())
print(0 if s < x or (s - x) & (2 * x + 1) else 2 ** bin(x).count('1') - 2 * (s == x))

s, x = list(map(int, input().split()))
print(0 if s < x or (s - x) & (2 * x + 1) else 2 ** bin(x).count('1') - 2 * (s == x))


s, x = list(map(int, input().split()))
print(0 if s < x or (s - x) & (2 * x + 1) else 2 ** bin(x).count('1') - 2 * (s == x))


s,x=list(map(int,input().split()))
jj=1 if s>=x and (s-x)/2==(s-x)//2 else 0
xx=bin(x)[2:]
aa=bin((s-x)//2)[2:]
if len(xx)<len(aa): xx=(len(aa)-len(xx))*'0'+xx
else: aa=(len(xx)-len(aa))*'0'+aa
#print(xx,aa)
for i in range(len(xx)):
    if xx[i]=='0': continue
    elif xx[i]=='1':
        if aa[i]=='0':
            jj*=2
        else:
            jj=0
if (s-x)//2==0 and jj>=2: jj-=2 
print(jj)  

##////////////////      //////        ///////      //             ///////     //  //   //
##////          //    ///   ///     ///    ///     //            ///  ///     ////     //
##////    ////       ///     ///   ///      ///    //           /////////     ////     ///////
##////     /////    ///       /// ///        ///   //          ///    ///     ////     //   //
##//////////////     ///////////   ///////////     //////     ///     ///     //  //   //   //





import sys
import io

stream_enable = 0

inpstream = """
9 5
"""

if stream_enable:
    sys.stdin = io.StringIO(inpstream)
    input()

def inpmap():
    return list(map(int, input().split()))

a, b = inpmap()
if b > a:
    print(0)
    return
flag = a == b
# a = bin(a)[2:]
# b = bin(b)[2:]
# ln = max(len(a), len(b))
# if len(a) > len(b):
#     b = "0" * (len(a) - len(b)) + b
# elif len(b) > len(a):
#     a = "0" * (len(b) - len(a)) + a
# ln = len(a)
# print(a)
# print(b)
b = "0" * (len(bin(a)) - len(bin(b))) + bin(b)[2:]
# print(b)
res = 1
p = 2 ** (len(b) - 1)
for x in b:
    if x == '1':
        res *= 2
        a -= p
    elif a >= p * 4 - 1:
        print(0)
        return
    elif a >= p * 2:
        a -= p * 2
    p //= 2
    # print(a)
if a:
    print(0)
    return
if flag:
    res -= 2
print(res)


s,x=list(map(int,input().split()))
f=0
if s==x:
    f=-2
aa=s-x
if aa%2==1 or aa<0:
    print(0)
else:
    a=aa//2
    #print(a,s)
    out=1
    for i in range(64):
        xx=x%2
        aa=a%2
        if xx==1:
            out*=2
            if aa==1:
                out=0
        x//=2
        a//=2
    print(out+f)
                
        
        
    


s, x = list(map(int, input().split()))

print(0 if s < x or (s - x) & (2 * x + 1) else 2 ** bin(x).count('1') - 2 * (s == x))




# Made By Mostafa_Khaled


s,x=list(map(int,input().split()))
print(0 if (s<x or (s-x)%2 or ((s-x)//2)&(x)!=0) else 2**(list(bin(x)).count('1'))-2*(s==x) )


s, x = map(int, input().split())
a, b = 1, 0
for i in range(50):
    c, d = s & (1 << i), x & (1 << i)
    # print(i, a, b, c, d)
    if c == d:
        if c:
            a, b = 2 * a, 0
        else:
            a, b = a, a
    else:
        if c:
            a, b = b, b
        else:
            a, b = 0, 2 * b
if s == x:
    a -= 2
print(a)

s,x=map(int,input().split())
b=s-x
b=list(bin(s-x))
b=b[2:]
a=list(bin(x))
a=a[2:]
#print(a)
al=len(a)
bl=len(b)
c=[]
if(bl>al):
	for i in range(bl-al):
		c.append('0')
	c.extend(a)
	a=c
else:
	for i in range(al-bl):
		c.append('0')
	c.extend(b)
	b=c
p=0
bl=len(b)
for i in range(bl-1):
	if(b[i]=='1'):
		if(a[i+1]=='1'):
			#print("hello")
			p=1
bl=len(b)
if(b[bl-1]=='1'):
	#print("hello")
	p=1
if(x>s):
	print("0")
elif(p==1):
	#print("hhh")
	print("0")
else:
	if(s==x):
		print(2**(a.count('1'))-2)
	elif(x==0):
		print("1")
	else:
		print(2**(a.count('1')))

suma,xor=list(map(int,input().split()))
mitad=round((suma-xor)/2)
if(mitad<0 or mitad*2+xor!=suma or (mitad&xor)!=0):
    print(0)
else:
    print(2**(bin(xor).count("1"))-2*(suma==xor))


from sys import stdin,stdout
r,w = stdin.readline,stdout.write
s,x = map(int,r().split());andShft = s-x
w('%i\n' %(0 if andShft&1 or s<x or x&(andShft>>1) else 2**(f'{x:b}'.count('1')) - (2 if s == x else 0)))

from sys import stdin,stdout
r,w = stdin.readline,stdout.write
s,x = map(int,r().split());andShft = s-x
w('%i\n' %(0 if andShft&1 or s<x or x&(andShft>>1) else 2**(f'{x:b}'.count('1')) - (2 if s == x else 0)))

R = lambda: map(int, input().split())
s, x = R()
if s < x or (s - x) & 1:
    print(0)
    return
u, d = (s - x) // 2, x
res = 1
while u or d:
    uu, dd = u & 1, d & 1
    if uu and dd:
        res *= 0
    elif uu == 0 and dd == 1:
        res *= 2
    u, d = u >> 1, d >> 1
if s == x:
    res = max(0, res - 2)
print(res)

from sys import stdin,stdout
r,w = stdin.readline,stdout.write
s,x = map(int,r().split());andShft = s-x
w('%i\n' %(0 if andShft&1 or s<x or x&(andShft>>1) else 2**(f'{x:b}'.count('1')) - (2 if s == x else 0)))

s, x = map(int, input().split())
if s < x:
	print(0)
	return
f = x
if (s - x) % 2 == 1:
	print(0)
	return
x = bin(x)[2::]
y = (s - f) // 2
y = bin(y)
y = y[2:]
if len(x) > len(y):
	y = "0" * (len(x) - len(y)) + y
else:
	x = "0" * (len(y) - len(x)) + x
k = 0
for i in range(len(x)):
	if x[i] == "1":
		k += 1
	if int(x[i]) + int(y[i]) == 2:
		print(0)
		return
if s == f:
	print(2 ** k - 2)
	return
print(2 ** k)

s, x = list(map(int, input().split()))
print(((s-x)&(x+x+1)==0 and x <= s) * (2 ** bin(x).count('1') - 2 * (s == x)))


def codechef(s,x):
    #cook your dish here
    flag = 0
    a = (s-x)//2
    if (s-x)/2 != a:
        print(0)
        return
    if s == x:
        flag = 1
    
    if a < 0:
        print(0)
        return
    a = str(bin(a))
    x = str(bin(x))
    a = a[2:]
    x = x[2:]
    l = (len(a)-len(x))
    if l>0:
        x = ("0"*l)+x
    else:
        a = ("0"*(-l))+a
    res = 1
    for i in range(len(a)):
        if x[i]=="1" and a[i]=="0":
            res *= 2
        elif x[i]=="1" and a[i]=="1":
            print(0)
            return
    if flag:
        res -= 2
        
    
    print(res)

    
    
    

def __starting_point():
  
    s,x = list(map(int, input().split()))
    codechef(s,x)
    
    
                
            
        

__starting_point()