#include using namespace std; typedef long long ll; typedef long double ld; #define rep(i, a, n) for (int i = (a); i < (n); i++) #define per(i, a, n) for (int i = (n) - 1; i >= (a); i--) typedef vector vd; const ld eps = 1e-12; int solveLinear(vector& A, vd& b, vd& x) { int n = A.size(), m = x.size(), rank = 0, br, bc; if (n) assert(A[0].size() == m); vector col(m); iota(col.begin(), col.end(), 0); rep(i,0,n) { /*rep(ii,0,n) { rep(jj,0,m) { cout << A[ii][jj] << "\t"; } cout << endl; } cout << endl;*/ ld v, bv = 0; rep(r,i,n) rep(c,i,m) if ((v = fabs(A[r][c])) > bv) br = r, bc = c, bv =v; /*if (bv <= eps) { rep(j,i,n) if (fabs(b[j]) > eps) return -1; break; }*/ swap(A[i], A[br]); swap(b[i], b[br]); swap(col[i], col[bc]); rep(j,0,n) swap(A[j][i], A[j][bc]); // bv = 1/A[i][i]; rep(j,i+1,n) { // assert(A[j][i] % A[i][i] == 0); ld fac = A[j][i] / A[i][i]; b[j] -= fac * b[i]; rep(k,i+1,m) A[j][k] -= fac*A[i][k]; } rank++; } x.assign(m, 0); for (int i = rank; i--;) { b[i] /= A[i][i]; x[col[i]] = b[i]; rep(j,0,i) b[j] -= A[j][i] * b[i]; } return rank; } int n, k; vector A; vd b; int node_cnt = 0; ld coef = 1; struct Node { Node * sons[2]; int index; Node() { sons[0] = NULL, sons[1] = NULL; index = node_cnt; ++node_cnt; } ~Node() { delete sons[0]; delete sons[1]; } void add(string &s, int fr) { if (fr >= s.size()) { return; } else { int x = s[fr] == 'T'; if (sons[x] == NULL) { sons[x] = new Node(); } sons[x]->add(s, fr+1); } } Node* reach(vector& path, int fr) { if (fr >= path.size()) return this; if (sons[path[fr]] != NULL) { return sons[path[fr]]->reach(path, fr+1); } else { return NULL; } } void go(vector& path, Node& root) { //for(auto x : path) cout << x; //cout << endl; A[index][index] = coef; if (sons[0] == NULL && sons[1] == NULL) { return; } b[index] = coef; rep(i,0,2) { if (sons[i] != NULL) { A[index][sons[i]->index] -= coef / 2; path.push_back(i); sons[i]->go(path, root); path.pop_back(); } else { path.push_back(i); rep(fr,1,path.size()+1) { Node* reached = root.reach(path, fr); if (reached != NULL) { A[index][reached->index] -= coef / 2; break; } } path.pop_back(); } } } }; int main(void) { ios_base::sync_with_stdio(false); cout << fixed << setprecision(9); cin >> n >> k; vector a(n); Node root; coef = (1ll<<(k+1)); coef = 1; rep(i,0,n) { cin >> a[i]; root.add(a[i], 0); } A.resize(node_cnt, vd(node_cnt, 0)); b.resize(node_cnt, 0); vector path; root.go(path, root); /*rep(i,0,node_cnt) { rep(j,0,node_cnt) cout << A[i][j] << "\t"; cout << " = " << b[i] << endl; }*/ vd x(node_cnt); int rank = solveLinear(A, b, x); assert(rank != -1); //rep(i,0,x.size()) cout << x[i] << endl; cout << llround(x[0]) << endl; }