#include <bits/stdc++.h>
using namespace std;
long long s, x;
bool aras[65];
bool arax[65];
int slen;
int xlen;
void dow() {
  slen = 0;
  xlen = 0;
  for (int i = 0; i <= 60; i++) {
    if (s & (1LL << i)) {
      slen = i + 1;
    }
  }
  for (int i = 0; i <= slen - 1; i++) {
    if (s & (1LL << i)) {
      aras[i] = 1;
    } else {
      aras[i] = 0;
    }
  }
  for (int i = 0; i <= 60; i++) {
    if (x & (1LL << i)) {
      xlen = i + 1;
    }
  }
  for (int i = 0; i <= xlen - 1; i++) {
    if (x & (1LL << i)) {
      arax[i] = 1;
    } else {
      arax[i] = 0;
    }
  }
}
long long dp[65][2][2][2];
long long func(int pos1, bool car, bool chk1, bool chk2) {
  if ((pos1 == slen)) {
    if (chk1 && chk2 && (car == 0)) {
      return 1;
    }
    return 0;
  }
  if (dp[pos1][car][chk1][chk2] != -1) {
    return dp[pos1][car][chk1][chk2];
  }
  long long ans = 0;
  if ((arax[pos1] == 1) && (pos1 < xlen)) {
    if (car) {
      if (aras[pos1] == 0) {
        ans += func(pos1 + 1, 1, chk1, 1);
        ans += func(pos1 + 1, 1, 1, chk2);
      }
    } else {
      if (aras[pos1] == 1) {
        ans += func(pos1 + 1, 0, chk1, 1);
        ans += func(pos1 + 1, 0, 1, chk2);
      }
    }
  } else {
    if (car) {
      if (aras[pos1] == 1) {
        ans += func(pos1 + 1, 1, 1, 1);
      }
    } else {
      if (aras[pos1] == 0) {
        ans += func(pos1 + 1, 1, 1, 1);
      }
    }
    if (car) {
      if (aras[pos1] == 1) {
        ans += func(pos1 + 1, 0, chk1, chk2);
      }
    } else {
      if (aras[pos1] == 0) {
        ans += func(pos1 + 1, 0, chk1, chk2);
      }
    }
  }
  return dp[pos1][car][chk1][chk2] = ans;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  ;
  cin >> s >> x;
  if (x > s) {
    cout << 0 << "\n";
    return 0;
  }
  dow();
  memset((dp), -1, sizeof(dp));
  cout << func(0, 0, 0, 0) << "\n";
  return 0;
}
