#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long b, long long p) {
  if (p == 0) return 1;
  long long my = bigmod(b, p / 2);
  my *= my;
  my %= 1000000007;
  if (p & 1) my *= b, my %= 1000000007;
  return my;
}
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(int n, int pos) { return (bool)(n & (1 << pos)); }
long long ara[100], bra[100], a, b;
void make(long long x, long long f) {
  if (f)
    for (long long i = 44; i >= 0; i--) ara[i] = x % 2, x /= 2;
  else
    for (long long i = 44; i >= 0; i--) bra[i] = x % 2, x /= 2;
}
bool visit[100][5];
long long dp[100][5];
long long fun(long long pos, long long car) {
  if (pos == 0) return car == 0;
  if (visit[pos][car]) return dp[pos][car];
  long long ret = 0;
  long long x = bra[pos];
  if (car == 0) {
    long long y = ara[pos];
    if (y == 1 && x == y) {
      ret += 2 * fun(pos - 1, 0);
    }
    if (y == 0 && x == y) {
      ret += fun(pos - 1, 0);
      ret += fun(pos - 1, 1);
    }
  } else {
    long long y = ara[pos];
    if (y == 1 && x != y) {
      ret += fun(pos - 1, 0);
      ret += fun(pos - 1, 1);
    }
    if (y == 0 && x != y) {
      ret += 2 * fun(pos - 1, 1);
    }
  }
  visit[pos][car] = 1;
  return dp[pos][car] = ret;
}
int main() {
  scanf("%lld %lld", &a, &b);
  make(a, 1);
  make(b, 0);
  long long my = fun(44, 0);
  if (a == b) my -= 2;
  printf("%lld", my);
  printf("\n");
  return 0;
}
