#include using namespace std; int main() { int n, m; cin >> n >> m; int ans = 0; for (int i=0; i<30; i++) { int x = (n >> i) & 1, y = (m >> i) & 1; int k; if (i % 2 == 0) { if (y == 0) k = 0; else if (x == 1) k = 1; else { cout << -1 << endl; return 0; } } else { if (x == y) k = 0; else if (x == 0 && y == 1) k = 1; else { cout << -1 << endl; return 0; } } ans |= k << i; } cout << ans << endl; }