#include <bits/stdc++.h>
using namespace std;
long long n, m, st, ans = 1;
int main() {
  scanf("%I64d %I64d", &n, &m);
  for (int i = 40; i >= 0; i--) {
    if (n & (1LL << i)) {
      st = i;
      break;
    }
    if (m & (1LL << i)) {
      st = i;
      break;
    }
  }
  bool ok = false, reach = false;
  for (int i = st; i >= 0; i--) {
    int x, y;
    if (n & (1LL << i))
      x = 1;
    else
      x = 0;
    if (m & (1LL << i))
      y = 1;
    else
      y = 0;
    if (ok) x += 2;
    ok = false;
    if (x == 0 && y == 0) {
    } else if (x == 0) {
      printf("0\n");
      return 0;
    } else if (x == 1 && y == 0) {
      ok = true;
    } else if (x == 1)
      ans *= 2LL;
    else if (x == 2 && y == 0) {
      reach = true;
    } else if (x == 2)
      ans *= 2LL, ok = true;
    else if (x == 3 && y == 0)
      ok = true, reach = true;
    else {
      printf("0\n");
      return 0;
    }
  }
  if (ok) {
    printf("0\n");
    return 0;
  }
  if (!reach) ans -= 2;
  printf("%I64d\n", ans);
  return 0;
}
