eolymp
bolt
Try our new interface for solving problems
Problems

Bitwise Equations

Bitwise Equations

You are given two positive integers \textbf{x} and \textbf{k}. Find the \textbf{k}-th smallest positive integer \textbf{y} (where \textbf{k} is \textbf{1}-based) for which the following equation holds: \textbf{x} + \textbf{y} = \textbf{x} | \textbf{y} where '|' denotes the bitwise \textbf{OR} operator. \InputFile Each line is a separate test case which contains two integers \textbf{x} and \textbf{k} (\textbf{1 }≤ \textbf{x}, \textbf{k} ≤ \textbf{2}*\textbf{10^9}). \OutputFile For each test case print in a separate line the \textbf{k}-th smallest positive integer \textbf{y} for which the given above equation holds.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5 1
5 5
10 3
1 1000000000
Output example #1
2
18
5
2000000000