#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int hmb(ull n){
int ret = 0;
while(n >= 2){
n /= 2;
ret++;
}
return ret;
}
int hm1(ull n){
int ret = 0;
while(n > 0){
if(n & 1 != 0) ret++;
n >>= 1;
}
return ret;
}
ull pw(int base, int pot){
if(pot == 0) return 1;
ull r = pw(base, pot/2);
r *= r;
if(pot % 2 == 1) r *= base;
return r;
}
ull s, x;
int nbits;
vi a, b, c, vx, vs, res;
bool backt(int bit, int carry){
if(bit >= nbits) return true;
bool sol = false;
if(vx[bit] == 0){
if(vs[bit] != carry) return false;
sol |= backt(bit + 1, 0);
sol |= backt(bit + 1, 1);
}
if(vx[bit] == 1 && vs[bit] != carry){
sol |= backt(bit + 1, carry);
}
return sol;
}
int main(){
cin >> s >> x;
nbits = hmb(s) + 1;
int nbx = hmb(x) + 1;
int h1x = hm1(x);
a.assign(nbits, 0);
b.assign(nbits, 0);
c.assign(nbits, 0);
res.assign(nbits, 0);
ull ts = s;
for(int i = 0; i < nbits; i++){
vs.push_back(s & 1);
s >>= 1;
}
ull tx = x;
for(int i = 0; i < nbx; i++){
vx.push_back(x & 1);
x >>= 1;
}
bool r = backt(0,0);
ull val = pw(2,h1x);
if(ts == tx) val -= 2;
if(r) cout << val << endl;
else cout << 0 << endl;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWF0aC5oPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR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