#include <bits/stdc++.h>
using namespace std;
long long su, xo;
map<long long, long long> fh[25], sh[25];
vector<pair<long long, long long> > h1, h2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> su >> xo;
  if (xo & 1)
    fh[0][1] = 2;
  else {
    fh[0][0] = 1;
    fh[0][2] = 1;
  }
  for (long long i = 1; i <= 20; i++) {
    if (xo & ((long long)1 << i)) {
      for (auto u : fh[i - 1])
        fh[i][u.first + ((long long)1 << i)] = (long long)2 * u.second;
      continue;
    } else {
      for (auto u : fh[i - 1]) {
        fh[i][u.first] += u.second;
        fh[i][u.first + ((long long)1 << (i + 1))] += u.second;
      }
    }
    fh[i - 1].clear();
  }
  if (xo & ((long long)1 << (long long)21))
    sh[0][((long long)1 << (long long)21)] = 2;
  else {
    sh[0][0] = 1;
    sh[0][((long long)1 << (long long)22)] = 1;
  }
  for (long long i = 22; i <= 40; i++) {
    if (xo & ((long long)1 << i)) {
      for (auto u : sh[i - 1 - 21])
        sh[i - 21][u.first + ((long long)1 << i)] = (long long)2 * u.second;
    } else {
      for (auto u : sh[i - 1 - 21]) {
        sh[i - 21][u.first] += u.second;
        sh[i - 21][u.first + ((long long)1 << (i + 1))] += u.second;
      }
    }
    sh[i - 22].clear();
  }
  for (auto u : fh[20]) h1.push_back(u);
  for (auto u : sh[19]) h2.push_back(u);
  sort(h1.begin(), h1.end());
  sort(h2.begin(), h2.end());
  long long ans = 0;
  for (auto u : h1) {
    long long l = 0, r = (long long)(h2.size()) - 1, mid;
    while (l < r) {
      mid = (l + r) >> 1;
      if (u.first + h2[mid].first >= su)
        r = mid;
      else
        l = mid + 1;
    }
    if (u.first + h2[l].first != su) continue;
    ans += u.second * h2[l].second;
  }
  if (xo == su) ans -= 2;
  cout << ans << '\n';
  cout.flush();
  return 0;
}
