#include <bits/stdc++.h>
using namespace std;
const long long MAX_S = 100 + 10;
string reverseString(string s) {
  string ans = "";
  for (long long i = s.size() - 1; i >= 0; i--) {
    ans += s[i];
  }
  return ans;
}
string toBin(long long a) {
  long long temp = a;
  string ans = "";
  while (temp) {
    if (temp % 2 == 0) {
      ans += '0';
    } else {
      ans += '1';
    }
    temp /= 2;
  }
  for (long long i = ans.size(); i < MAX_S; i++) {
    ans += '0';
  }
  return ans;
}
long long calculate(string s, string x) {
  long long ans = 1;
  int ov = 0;
  for (long long i = 0; i < s.size() - 2; i++) {
    if (s[i] == '0' && x[i] == '0' && ov == 0) {
      if (s[i + 1] == '0' && x[i + 1] == '0') {
        ov = 0;
        continue;
      }
      if (s[i + 1] == '1' && x[i + 1] == '0') {
        ov = 1;
        continue;
      }
      if (s[i + 1] == '1' && x[i + 1] == '1') {
        ov = 0;
        continue;
      }
      if (s[i + 1] == '0' && x[i + 1] == '1') {
        ov = 1;
        continue;
      }
    }
    if (s[i] == '0' && x[i] == '0' && ov == 1) {
      return 0;
    }
    if (s[i] == '0' && x[i] == '1' && ov == 0) {
      return 0;
    }
    if (s[i] == '0' && x[i] == '1' && ov == 1) {
      ans *= 2;
      ov = 1;
      continue;
    }
    if (s[i] == '1' && x[i] == '0' && ov == 0) {
      return 0;
    }
    if (s[i] == '1' && x[i] == '0' && ov == 1) {
      if (s[i + 1] == '0' && x[i + 1] == '0') {
        ov = 0;
        continue;
      }
      if (s[i + 1] == '1' && x[i + 1] == '0') {
        ov = 1;
        continue;
      }
      if (s[i + 1] == '1' && x[i + 1] == '1') {
        ov = 0;
        continue;
      }
      if (s[i + 1] == '0' && x[i + 1] == '1') {
        ov = 1;
        continue;
      }
    }
    if (s[i] == '1' && x[i] == '1' && ov == 0) {
      ans *= 2;
      ov = 0;
      continue;
    }
    if (s[i] == '1' && x[i] == '1' && ov == 1) {
      return 0;
    }
  }
  int flag = 0;
  for (long long i = s.size() - 2; i >= 0; i--) {
    if (s[i] != x[i]) {
      flag = 1;
    }
  }
  if (flag == 0) {
    ans -= 2;
  }
  flag = 0;
  int flag2 = 0;
  if (s[0] == '0') {
    flag2 = 1;
    for (int i = 0; i < s.size(); i++) {
      if (x[i] == '1') {
        flag = 1;
      }
    }
  }
  if (flag2 == 1 && flag == 0) {
  }
  return ans;
}
int main() {
  long long s, x;
  cin >> s >> x;
  string strings, stringx;
  strings = toBin(s);
  stringx = toBin(x);
  cout << calculate(strings, stringx) << endl;
}
