#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = 0; i < 31; ++i) {
        bool fAND = (a & (1 << i)) > 0;
        bool fOR = (b & (1 << i)) > 0;
        if (fAND && !fOR) {
            cout << 0 << "\n";
            return 0;
        }

        if (fAND || !fOR) continue;
        cnt++;
    }

    cout << (1 << max(cnt - 1, 0)) << "\n";
    return 0;
}