#include <bits/stdc++.h>
using namespace std;
unsigned long long c[43][43];
int main() {
  unsigned long long sum, xx, lol, sisa, i, i2, ans;
  c[0][0] = 1;
  c[1][0] = 1;
  c[1][1] = 1;
  for (i = 2; i <= 40; ++i) {
    c[i][0] = 1;
    for (i2 = 1; i2 <= i; ++i2) {
      c[i][i2] = c[i - 1][i2 - 1] + c[i - 1][i2];
    }
  }
  cin >> sum >> xx;
  if (xx == 0) {
    cout << 1 << endl;
    return 0;
  }
  lol = __builtin_popcountll(xx);
  sisa = sum - xx;
  if (sisa % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (sisa == 0) {
    ans = 0;
    for (i = 1; i < lol; ++i) {
      ans += c[lol][i];
    }
    cout << ans << endl;
    return 0;
  }
  sisa = sisa / 2;
  long long tmpis = sisa;
  sisa = sisa ^ xx;
  sisa = sisa - xx;
  if (sisa - tmpis == 0) {
    ans = 0;
    for (i = 0; i <= lol; ++i) ans += c[lol][i];
    cout << ans << endl;
  } else
    cout << 0 << endl;
}
