How many binary sequences

No attempts yetTime limit3sMemory limit256 MB

Problem

You are given a set BB of binary sequences of length KK. Every element of BB is a sequence of KK values, each of them 00 or 11.

An integer sequence ZiZ_i is built by this process.

  1. Pick a sequence X=(x1,x2,,xK)X = (x_1, x_2, \dots, x_K) from BB.
  2. Pick a sequence Y=(y1,y2,,yK)Y = (y_1, y_2, \dots, y_K) from BB with dist(X,Y)2\mathrm{dist}(X, Y) \le 2. Here dist(X,Y)\mathrm{dist}(X, Y) is the Hamming distance of the two sequences, the number of positions where the two values differ. For example, dist((1,0,1,1),(1,1,1,1))=1\mathrm{dist}((1,0,1,1), (1,1,1,1)) = 1 and dist((1,0,1,1,1,0,1),(1,0,0,1,0,0,1))=2\mathrm{dist}((1,0,1,1,1,0,1), (1,0,0,1,0,0,1)) = 2. You may pick the same element as both XX and YY.
  3. Set Zi=(x1+y1,x2+y2,,xK+yK)Z_i = (x_1 + y_1, x_2 + y_2, \dots, x_K + y_K).

For example, Zi=(1,0,1,2,2)Z_i = (1,0,1,2,2) can be built from X=(1,0,0,1,1)X = (1,0,0,1,1) and Y=(0,0,1,1,1)Y = (0,0,1,1,1).

You are given NN integer sequences Z1,Z2,,ZNZ_1, Z_2, \dots, Z_N built this way. Among all sets BB that can build all NN of them, find one with the fewest elements and print how many elements it has.

Input

The first line contains KK and NN, separated by one space. (1K201 \le K \le 20, 1N241 \le N \le 24)

Each of the next NN lines contains one sequence ZiZ_i. The jj-th character of the ii-th line is the value of Zi,jZ_{i,j}, and there is no separator between characters. Each value is 00, 11, or 22, and each line contains at most two 11s, so every given ZiZ_i can be built by the process above.

Output

Print the minimum number of elements of the set BB.