#include <bits/stdc++.h>
using namespace std;
const int N = 60;
long long n, m, f[N], ans;
void find(int k, long long n, long long sum) {
  if (n < 0 || n > f[k + 2]) return;
  if (!k) {
    if (!n) ans += sum;
    return;
  }
  int x = (m & f[k]) > 0;
  if (x == 1)
    find(k - 1, n - f[k], sum * 2);
  else {
    find(k - 1, n, sum);
    find(k - 1, n - 2 * f[k], sum);
  }
}
int main() {
  cin >> n >> m;
  f[1] = 1;
  for (int i = 2; i < N; i++) f[i] = f[i - 1] * 2;
  find(N - 3, n, 1);
  if (n == m) ans -= 2;
  cout << ans;
}
