n,m = list(map(int,input().split())) n = list(map(int,list(bin(n)[2:]))) m = list(map(int,list(bin(m)[2:]))) c = 0 ans = 0 while len(n) and len(m): c += 1 x,y = n.pop(),m.pop() if c%2 == 0: if y == x: continue elif y == 0 and x == 1: print(-1) exit() else: ans |= 1<>1)