#include <bits/stdc++.h>
using namespace std;
long long mem[45][2];
long long a, b;
long long dp(long long cur, long long carry) {
  if (cur == 40) return carry ? 0 : 1;
  long long &ret = mem[cur][carry];
  if (ret != -1) return ret;
  long long x = (((long long)1 << cur) & a) ? 1 : 0;
  long long y = (((long long)1 << cur) & b) ? 1 : 0;
  ret = 0;
  if (y) {
    if (x != carry) {
      if (carry)
        ret += (dp(cur + 1, 1) << 1);
      else
        ret += (dp(cur + 1, 0) << 1);
    }
  } else if (x == carry) {
    ret += dp(cur + 1, 1);
    ret += dp(cur + 1, 0);
  }
  return ret;
}
int main() {
  memset(mem, -1, sizeof(mem));
  scanf("%lld %lld", &a, &b);
  printf("%lld\n", a == b ? dp(0, 0) - 2 : dp(0, 0));
  return 0;
}
