#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const long long MOD = 1e9 + 7;
long long s, x;
int a[50], n, ans0[1 << 21], ans1[1 << 21];
void work(int* ans, int s, int t) {
  int len = (t - s + 1);
  for (int i = 0; i < (1 << len); i++) {
    int tem = 0;
    for (int j = 1; j <= len; j++)
      if ((i >> (j - 1)) & 1) {
        if (a[s + j - 1] == 0) tem += 1 << j;
        if (a[s + j - 1] == 1) tem += 1 << (j - 1);
      } else {
        if (a[s + j - 1] == 0) tem += 0;
        if (a[s + j - 1] == 1) tem += 1 << (j - 1);
      }
    ans[++ans[0]] = tem;
  }
}
int main() {
  cin >> s >> x;
  n = 0;
  long long pp = x;
  while (pp > 0) {
    a[++n] = pp & 1;
    pp = pp / 2;
  }
  int qq = 0;
  pp = s;
  while (pp > 0) {
    qq++;
    pp /= 2;
  }
  n = max(n, qq);
  if (x == 0) {
    if (s % 2 == 0 && ((s / 2) xor (s / 2)) == 0) {
      cout << 1;
      return 0;
    }
    cout << 0 << endl;
    return 0;
  }
  if (x == 1) {
    if (s % 2 == 1 && ((s / 2 + 1) xor (s / 2)) == 1) {
      cout << 1;
      return 0;
    }
    cout << 0 << endl;
    return 0;
  }
  int t = n / 2;
  work(ans0, 1, t);
  work(ans1, t + 1, n);
  sort(ans0 + 1, ans0 + ans0[0] + 1);
  long long ans = 0;
  for (int i = 1; i <= ans1[0]; i++) {
    long long tem = s - (((long long)ans1[i]) << t);
    ans += upper_bound(ans0 + 1, ans0 + ans0[0] + 1, tem) -
           lower_bound(ans0 + 1, ans0 + ans0[0] + 1, tem);
  }
  if ((s xor 0) == x) ans -= 2;
  if (((s / 2) xor (s / 2)) == x && s % 2 == 0) ans -= 1;
  cout << ans << endl;
}
