#include #define itrep(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr) using namespace std; int to_num(string s) { int ret = 0; for(int i = 0; i < (int)s.size(); ++i){ char c = s[i]; ret |= (c - '0') << (i * 3); } return ret; } int main(){ int N, K; cin >> N >> K; vector mag(N); for(auto& x : mag){ string s; cin >> s; x = to_num(s); } vector visited(1 << (K * 3)); for(auto& sv : mag){ if(visited[sv]){ continue; } vector stk = { sv }; while(!stk.empty()){ int v = stk[stk.size() - 1]; stk.pop_back(); for(int i = 0; i < K; ++i){ int k = i * 3; if(((v >> k) & 7) == 0){ continue; } int nv = v - (1 << k); if(visited[nv]){ continue; } visited[nv] = true; stk.push_back(nv); } } } int ans = 0; for(auto& x : mag){ if(!visited[x]){ continue; } ++ans; } cout << ans << endl; return 0; }