#include <bits/stdc++.h>
using namespace std;
long long s[1000], x[1000], size;
void tob(long long a, long long arr[], long long& len) {
  len = 0;
  while (a != 0) {
    arr[len++] = a % 2;
    a /= 2;
  }
}
long long DP(long long n, long long carry) {
  if (n >= size) return 1 - carry;
  if (x[n] == 1) {
    if (((carry + 1) % 2) == s[n]) {
      return 2 * DP(n + 1, carry);
    } else
      return 0;
  } else {
    long long ans = 0;
    if ((carry) == s[n]) {
      ans += DP(n + 1, 0);
    }
    if (((carry + 2) % 2) == s[n]) {
      ans += DP(n + 1, 1);
    }
    return ans;
  }
}
void solve(long long n, long long m) {
  long long len1, len2, ans;
  tob(n, s, len1);
  tob(m, x, len2);
  size = max(len1, len2);
  ans = DP(0, 0);
  if (n == m)
    cout << ans - 2 << endl;
  else
    cout << ans << endl;
}
int main() {
  long long n, m;
  cin >> n >> m;
  solve(n, m);
  return 0;
}
