cswork / OAOpen practice workspace

SnowflakeOA #47

Can You Count the Bit Strings?

Estimated MediumJudge-ready

Topics (AI-labelled)Bits & MathTree & Game DP

Represent each given integer as exactly n bits (leading zeros allowed). For each original string, any zero bits may be flipped to 1; an original 1 cannot be changed to 0, and flipping nothing is also allowed. Find the size of the union of all results produced by all original strings; duplicate results are counted once, and no modulus is taken.

Input

The first line contains n k, and the second line contains k integers. This site adds 1≤n≤20, 1≤k≤100000, and 0≤integer<2ⁿ; the input may contain duplicates.

Output

Output the single integer required by the problem.

Example 1

Input:

3 2
1 2

Output:

6

Example 2

Input:

2 2
3 3

Output:

1

Example 3

Input:

4 2
0 15

Output:

16

Example notes

The answers to the three public examples are, in order: 6; 1; 16. The examples were checked by independent enumeration, state search, or direct simulation.

Editorial

Loading solution…