Bleed Magic


Submit solution

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

Author:
Problem type
Allowed languages
C++, Java, Python

Rishi and his gang of wizards are hunting the Radiant Sky Pheonix, a legendary bird they're sure will make for a good kebab. Since the phoenix is a magical creature, the wizards must use magical attacks to defeat it.

There are n wizards, each with a power p_i. To launch an attack on the phoenix, the wizards combine all their powers using a bitwise OR to obtain a total power p_t. For the attack to succeed, p_t must be at least x.

However, these attacks are tiring! After each attack, exactly one bit from exactly one of the wizards' powers must change from set to unset (1 \rightarrow 0). For example, if a wizard has a power of 11 (1011 in binary), then their power could change to 10 (1010), 9 (1001) or 3 (0011) after an attack. The wizards get to choose who loses a bit, and which bit is cleared.

Assuming the wizards play optimally, determine the maximum number of attacks they can perform on the phoenix before their combined power falls below x.

Input

The first line contains a two integers, n and x (1 \leq n, x \leq 2026), the number of wizards in Rishi's gang, and the power needed to make a successful attack.

The second line contains n integers, p_1, \dots, p_n (1 \leq p_i \leq 2026), where p_i is the power of the ith wizard.

Output

Output the maximum number of attacks the wizards can make, while their power stays above x.

Example

Input 1
3 10
11 9 4
Output 1
5

The wizards can make 5 attacks in total. Below is one way they could achieve this, although it is not the only way.

Initial State:
Wizard 1: 11    (1011)
Wizard 2: 9     (1001)
Wizard 3: 4     (0100)
Total Power: 15 (1111)

After Attack 1:
Wizard 1: 10    (1010) [lost fourth bit]
Wizard 2: 9     (1001)
Wizard 3: 4     (0100)
Total Power: 15 (1111)

After Attack 2:
Wizard 1: 2     (0010) [lost first bit]
Wizard 2: 9     (1001)
Wizard 3: 4     (0100)
Total Power: 15 (1111)

After Attack 3:
Wizard 1: 2     (0010)
Wizard 2: 8     (1000) [lost fourth bit]
Wizard 3: 4     (0100)
Total Power: 14 (1110)

After Attack 4:
Wizard 1: 2     (0010)
Wizard 2: 8     (1000)
Wizard 3: 0     (0000) [lost second bit]
Total Power: 10 (1010)

After Attack 5:
Wizard 1: 0     (0000) [lost third bit]
Wizard 2: 8     (1000)
Wizard 3: 0     (0000)
Total Power: 8  (1000)
Input 2
8 7
1 2 3 4 5 6 7 8
Output 2
13
Input 3
14 10
1 2 3 4 5 6 7 1 2 3 4 5 6 7
Output 3
0

Comments

There are no comments at the moment.