#include using namespace std; int main() { int m, n; cin >> n >> m; bitset<30> bm(m); bitset<30> bn(n); bool istrue = 1; for(int i = 0; i<30; i++){ if((i%2 == 0 && (bm[i] == 1 && bn[i] == 0)) || (i%2!= 0 &&(bn[i] == 1 && bm[i] == 0))){ istrue = 0; break; }} if(istrue == 0) cout << -1; else{ bitset<30> ans; for(int i = 0; i<30;i++){ if(i%2 == 0) ans[i] = bm[i]; if(i%2!= 0){ if(bn[i] == 1) ans[i] = 0; else ans[i] = bm[i]; } } cout << ans.to_ulong();} }