#include <bits/stdc++.h>
using namespace std;
int const lim = 10000;
int sta[lim + 1] = {0}, sta1[lim + 3] = {0};
long long memo[lim + 3][2];
long long solve(int i, int rem) {
  if (i > 50 && rem == 0)
    return 1;
  else if (i > 50)
    return 0;
  long long &ret = memo[i][rem];
  if (ret != -1) return ret;
  ret = 0;
  if (sta[i] == 1 && ((rem + 1) % 2) == sta1[i])
    return ret = 2 * solve(i + 1, (rem + 1) / 2);
  else if (sta[i] == 1)
    return rem = 0;
  if (rem % 2 == sta1[i]) ret += solve(i + 1, 0);
  if ((rem + 2) % 2 == sta1[i]) ret += solve(i + 1, (rem + 2) / 2);
  return ret;
}
int main() {
  memset(memo, -1, sizeof memo);
  long long ans = 0;
  long long a, b;
  cin >> a >> b;
  if (a == b) ans -= 2;
  for (int i = 0; a; a /= 2, i++) sta1[i] = a % 2;
  for (int i = 0; b; b /= 2, i++) sta[i] = b % 2;
  ans += solve(0, 0);
  cout << ans << endl;
}
