N, M = map(int, input().split()) ans = 0 for bit in range(30): if bit % 2 == 0: if M >> bit & 1 == 1: if N >> bit & 1 == 0: ans = -1 break else: ans |= (1<> bit & 1 == 0 and N >> bit & 1 == 1: ans = -1 break elif M >> bit & 1 == 1 and N >> bit & 1 == 0: ans |= (1<