cho.sh
Notes
Loading...

X and K

Time limit

2s

Memory limit

128 MB

Problem

You are given two positive integers X and K. List all positive integers Y that satisfy the following equation in increasing order, and find the K-th smallest such Y.

text
X + Y = X | Y

Here, | denotes the bitwise OR operation.

Input

The first line contains two positive integers X and K, separated by a space.

Each of X and K is at most 2,000,000,000.

Output

Print the K-th smallest positive integer Y satisfying X + Y = X | Y.

The answer may be greater than 2^31 - 1.

X + Y = X | Y