#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long dp[64][2][2][2];
long long s, x;
long long solve(int bit, int carry, int a, int b) {
  if (dp[bit][carry][a][b] != -1) return dp[bit][carry][a][b];
  dp[bit][carry][a][b] = 0;
  if ((1LL << bit) > s) {
    if (!a || !b || carry || ((1LL << bit) <= x)) {
      return 0;
    }
    return dp[bit][carry][a][b] = 1;
  }
  bool XOR = false, SUM = false;
  if ((1LL << bit) & s) {
    SUM = true;
  }
  if ((1LL << bit) & x) {
    XOR = true;
  }
  if (!SUM && !XOR) {
    if (!carry) {
      dp[bit][carry][a][b] += solve(bit + 1, carry ^ 1, 1, 1);
      dp[bit][carry][a][b] += solve(bit + 1, carry, a, b);
    } else {
      return 0;
    }
  } else if (!SUM && XOR) {
    if (!carry) {
      return 0;
    } else {
      dp[bit][carry][a][b] += solve(bit + 1, carry, 1, b);
      dp[bit][carry][a][b] += solve(bit + 1, carry, a, 1);
    }
  } else if (SUM && !XOR) {
    if (!carry) {
      return 0;
    } else {
      dp[bit][carry][a][b] += solve(bit + 1, carry ^ 1, a, b);
      dp[bit][carry][a][b] += solve(bit + 1, carry, 1, 1);
    }
  } else if (SUM && XOR) {
    if (!carry) {
      dp[bit][carry][a][b] += solve(bit + 1, carry, 1, b);
      dp[bit][carry][a][b] += solve(bit + 1, carry, a, 1);
    } else {
      return 0;
    }
  }
  return dp[bit][carry][a][b];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> x;
  for (int i = 0; i < 64; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 2; ++k) {
        for (int l = 0; l < 2; ++l) {
          dp[i][j][k][l] = -1;
        }
      }
    }
  }
  long long fans = solve(0, 0, 0, 0);
  if (fans == -1) fans = 0;
  cout << fans << "\n";
  return 0;
}
