#arc155e. [arc155_e]Split and Square

[arc155_e]Split and Square

Problem Statement

For a set XX of non-negative integers, let f(X)f(X) denote the set of non-negative integers that can be represented as the bitwise mathrmXOR\\mathrm{XOR} of two integers (possibly the same) in XX. As an example, for X=lbrace1,2,4rbraceX=\\lbrace 1, 2, 4\\rbrace, we have f(X)=lbrace0,3,5,6rbracef(X)=\\lbrace 0, 3, 5, 6\\rbrace.

You are given a set of NN non-negative integers less than 2M2^M: S=lbraceA1,A2,dots,ANrbraceS=\\lbrace A_1, A_2, \\dots, A_N\\rbrace.

You may perform the following operation any number of times.

  • Divide SS into two sets T1T_1 and T2T_2 (one of them may be empty). Then, replace SS with the union of f(T1)f(T_1) and f(T2)f(T_2).

Find the minimum number of operations needed to make S=lbrace0rbraceS=\\lbrace 0\\rbrace.

What is bitwise mathrmXOR\\mathrm{XOR}?

The bitwise mathrmXOR\\mathrm{XOR} of non-negative integers AA and BB, AoplusBA \\oplus B, is defined as follows.

  • When AoplusBA \\oplus B is written in binary, the kk-th lowest bit (kgeq0k \\geq 0) is 11 if exactly one of the kk-th lowest bits of AA and BB is 11, and 00 otherwise.

For instance, 3oplus5=63 \\oplus 5 = 6 (in binary: 011oplus101=110011 \\oplus 101 = 110).
Generally, the bitwise mathrmXOR\\mathrm{XOR} of kk non-negative integers p1,p2,p3,dots,pkp_1, p_2, p_3, \\dots, p_k is defined as $(\\dots ((p_1 \\oplus p_2) \\oplus p_3) \\oplus \\dots \\oplus p_k)$, which can be proved to be independent of the order of p1,p2,p3,dots,pkp_1, p_2, p_3, \\dots, p_k.

Constraints

  • 1leqNleq3001 \\leq N \\leq 300
  • 1leqMleq3001 \\leq M \\leq 300
  • 0leqAi<2M0 \\leq A_i < 2^{M}
  • Ai(1leqileqN)A_i\\ (1\\leq i \\leq N) are pairwise distinct.
  • Each AiA_i is given with exactly MM digits in binary (possibly with leading zeros).
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN MM A1A_1 A2A_2 vdots\\vdots ANA_N

Output

Print the answer.


Sample Input 1

4 2
00
01
10
11

Sample Output 1

2

In the first operation, you can divide SS into $T_1=\\lbrace 0, 1\\rbrace, T_2=\\lbrace 2, 3\\rbrace$, for which $f(T_1) =\\lbrace 0, 1\\rbrace, f(T_2) =\\lbrace 0, 1\\rbrace$, replacing SS with lbrace0,1rbrace\\lbrace 0, 1\\rbrace.

In the second operation, you can divide SS into T1=lbrace0rbrace,T2=lbrace1rbraceT_1=\\lbrace 0\\rbrace, T_2=\\lbrace 1\\rbrace, making S=lbrace0rbraceS=\\lbrace 0\\rbrace.

There is no way to make S=lbrace0rbraceS=\\lbrace 0\\rbrace in fewer than two operations, so the answer is 22.


Sample Input 2

1 8
10011011

Sample Output 2

1

In the first operation, you can divide SS into T1=lbrace155rbrace,T2=lbracerbraceT_1=\\lbrace 155\\rbrace, T_2=\\lbrace \\rbrace, making S=lbrace0rbraceS=\\lbrace 0\\rbrace. Note that T1T_1 or T2T_2 may be empty.


Sample Input 3

1 2
00

Sample Output 3

0

We have S=lbrace0rbraceS=\\lbrace 0\\rbrace from the beginning; no operation is needed.


Sample Input 4

20 20
10011011111101101111
10100111100001111100
10100111100110001111
10011011100011011111
11001000001110011010
10100111111011000101
11110100001001110010
10011011100010111001
11110100001000011010
01010011101011010011
11110100010000111100
01010011101101101111
10011011100010110111
01101111101110001110
00111100000101111010
01010011101111010100
10011011100010110100
01010011110010010011
10100111111111000001
10100111111000010101

Sample Output 4

10