#include <bits/stdc++.h>
using namespace std;
void smain();
int main() {
  smain();
  return 0;
}
long long s, x;
long long naive() {
  long long res = 0;
  for (long long i = 0; i < s + 1; i++) {
    long long j = s - i;
    if (i == 0 || j == 0) continue;
    if ((i ^ j) == x) res += 1;
  }
  return res;
}
long long cnt[1 << 21];
long long solve() {
  long long mm = 1 << 20;
  memset(cnt, 0, sizeof(cnt));
  for (long long mask = 0; mask < mm; mask++) {
    long long comp = (x & (mm - 1)) ^ mask;
    cnt[mask + comp] += 1;
  }
  long long res = 0;
  for (long long mask = 0; mask < mm; mask++) {
    long long comp = ((x >> 20) & (mm - 1)) ^ mask;
    long long val = (comp << 20) + (mask << 20);
    long long rem = s - val;
    if (rem >= 0 && rem < (1 << 21)) {
      res += cnt[rem];
    }
  }
  if (s == x) res -= 2;
  return res;
}
void smain() {
  for (; cin >> s >> x;) {
    cout << solve() << endl;
  }
}
