Ambitious Utopion Osman

View as PDF

Submit solution


Points: 20
Time limit: 1.0s
Memory limit: 256M

Problem types

Ambitious Utopion Osman is a space ʞlıɯ delivery employee. They spend their days flying from planet to planet with their rocket, delivering ʞlıɯ. But the ʞlıɯ demand of their solar system is increasing day by day!

The amount of ʞlıɯ Ambitious Rocket carries would require complicated space maths in AUO's universe, but luckily for us, the calculations are simple. It is sufficient to XOR (bitwise xor operation) the distance to be traveled with the liters of lǝnɟ the rocket has.

AUO should always travel \(\mathbf{A_i}\) lightyears to reach the \(\mathbf{i}\)'th planet. It doesn't matter where the Ambitious Rocket is located.

AUO has \(\mathbf{M}\) liters of ʞlıɯ in total and AUO needs to visit \(\mathbf{N}\) planets in total. Can you calculate the maximum amount of lǝnɟ AUO can take on their rocket without the amount of ʞlıɯ they carry exceeding \(\mathbf{M}\)?

  • note: ʞlıɯ and lǝnɟ act differently from the matter we understand. Upon delivering ʞlıɯ, Ambitious Rocket's lǝnɟ doesn't decrease.

Input

The first line will include the integers \(\mathbf{N}\) and \(\mathbf{M}\).

The next will have \(\mathbf{N}\) positive integers in total. \(\mathbf{A_i}\) equals to the distance needs to be traveled to reach that planet.

Batch #1:
  • \(1 \leq \mathbf{N} \leq 100\)
  • \(1 \leq \mathbf{A_i} \leq 100\)
  • \(1 \leq \mathbf{M} \leq 10^4\)
Batch #2:
  • \(1 \leq \mathbf{N} \leq 10^5\)
  • \(1 \leq \mathbf{A_i} \leq 10^{12}\)
  • \(1 \leq \mathbf{M} \leq 10^{15}\)

Output

Print the amount of lǝnɟ AUO should put into the Ambitious Rocket.

  • If the amount of ʞlıɯ that can be delivered always exceedes \(\mathbf{M}\), print "-1".

Samples

Input:

6 20
3 4 3 1 3 1

Output:

3

Input:

6 40
3 8 4 4 6 9

Output:

7

Girdi:

5 10
3 2 4 4 12

Çıktı:

-1

Explanation

1. Input
  • \((3 \mathbin{\oplus} 3) + (3 \mathbin{\oplus} 4) + (3 \mathbin{\oplus} 3) + (3 \mathbin{\oplus} 1) + (3 \mathbin{\oplus} 3) + (3 \mathbin{\oplus} 1)\)
  • \(0 + 7 + 0 + 2 + 0 + 2 = 11 \leq 20\)
2. Input
  • \((7 \mathbin{\oplus} 3) + (7 \mathbin{\oplus} 8) + (7 \mathbin{\oplus} 4) + (7 \mathbin{\oplus} 4) + (7 \mathbin{\oplus} 6) + (7 \mathbin{\oplus} 9)\)
  • \(4 + 15 + 3 + 3 + 1 + 14 = 40 \leq 40\)
3. Input
  • For all non-negative integers, the amount of ʞlıɯ that can be delivered always exceeds \(\mathbf{M}\). Therefore there's no valid answer.