#include <bits/stdc++.h>
using namespace std;
long long int sum, x;
vector<long long int> v, power;
long long int ans;
int main() {
  cin >> sum >> x;
  long long int help1 = x;
  long long int help2 = 0;
  while (help1) {
    if (help1 % 2) help2++;
    v.push_back(help1 % 2);
    help1 /= 2;
  }
  long long int now = 1;
  for (int i = 0; i < help2; ++i) now *= 2;
  ans = now;
  now = 2;
  int t = v.size();
  for (int i = 0; i < 40 - t; ++i) v.push_back(0);
  for (int i = 0; i < v.size(); ++i) {
    if (!v[i]) power.push_back(now);
    now *= 2;
  }
  sum -= x;
  if (!sum) return cout << (ans - 2), 0;
  for (int i = power.size() - 1; i > -1; --i) {
    if (sum >= power[i]) sum -= power[i];
  }
  if (sum) return cout << 0, 0;
  cout << ans;
}
