#include <bits/stdc++.h>
using namespace std;
long long int dp[70][70][2][2];
bool vis[70][70][2][2] = {0};
int n = 60;
int test(long long int second, int i) {
  if (second & (1LL << i)) return 1;
  return 0;
}
long long int second, x;
long long int rec(int i, int c, bool inc1, bool inc2) {
  if (i == n) {
    if (c == 0 and inc1 and inc2) return 1;
    return 0;
  }
  if (vis[i][c][inc1][inc2]) return dp[i][c][inc1][inc2];
  vis[i][c][inc1][inc2] = 1;
  long long int &ret = dp[i][c][inc1][inc2];
  ret = 0;
  if (x & (1LL << i)) {
    if ((c + 1) % 2 == test(second, i)) {
      ret += rec(i + 1, (c + 1) / 2, inc1, 1);
      ret += rec(i + 1, (c + 1) / 2, 1, inc2);
    }
  } else {
    if (c % 2 == test(second, i)) {
      ret += rec(i + 1, c / 2, inc1, inc2);
    }
    if ((c + 2) % 2 == test(second, i)) {
      ret += rec(i + 1, (c + 2) / 2, 1, 1);
    }
  }
  return ret;
}
int main() {
  cin >> second >> x;
  cout << rec(0, 0, 0, 0);
}
