#include <bits/stdc++.h>
using namespace std;
long long fac[100009], s, x, pre[10009], ans;
void dfs(long long num, long long u, long long k, long long ok) {
  if (num == -1) {
    if (u == s) {
      ans += fac[k];
      if (!ok) ans -= 2;
    }
    return;
  }
  if (x & fac[num])
    dfs(num - 1, u + fac[num], k + 1, ok);
  else {
    int flag = 0;
    if (u + 2 * fac[num] <= s) flag = 1, dfs(num - 1, u + 2 * fac[num], k, 1);
    if (pre[num - 1] * 2 + u >= s) flag = 1, dfs(num - 1, u, k, ok);
  }
}
int main() {
  fac[0] = 1, pre[0] = 1;
  for (int i = 1; i <= 40; i++)
    fac[i] = 2 * fac[i - 1], pre[i] = pre[i - 1] + fac[i];
  cin >> s >> x;
  dfs(40, 0, 0, 0);
  cout << ans;
}
