import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        long y = scanner.nextLong();
        long k = scanner.nextLong();

        long notPossible = 0;
        long res = 0;

        for(long i = 10; i>=0; i--){
            long initial_num = 0;
            //get digit at current iteration in bin num 
            long g = y>>i;
            if ((g & 1) == 1){
                initial_num = 1;
            }
            else{
                initial_num = 0;
            }
            long final_num = 0;
            g = k>>i;
            if ((g & 1) == 1){
                final_num = 1;
            }
            else{
                final_num = 0;
            }
            if ( initial_num == final_num ){
                //then do nothing.. the res is anyway going to be 0 at i 
            }
            else{
                if ( initial_num == 0){
                    //then we need 1 at the ith pos of the res which we will || with to get final
                    // this case means that initial != final at i and initial doesnt have 1 which final has.. so 
                    // num we OR with needs to have a 1
                    res |= (1L << i);
                    // left shift because i want to place 1 at a specific pos
                    //LEFT SHIFT = “move 1 to position i”
                    /*
                    Right shift does the opposite: 1000 >> 1 = 0100
                    👉 It loses information (moves bits away)
                    8*/
                }
                else{
                    notPossible = -1;break;
                }
            }
        }
        if (notPossible == -1) {
            System.out.println(notPossible);
        } else {
            System.out.println(res);
        }
    }
}
