#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, k; cin >> n >> k; auto s = vec2d(n, k, 0); for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ char c; cin >> c; s[i][j] = c-'0'; } } auto to_int = [&](vector v){ int ans = 0; for(int i = 0; i < k; i++) ans = ans*5+v[i]; return ans; }; int mx = to_int(vector(k, 4)); vector> v(mx+1); for(int x = 0; x <= mx; x++){ vector u; int cur = x; for(int i = 0; i < k; i++){ u.push_back(cur%5); cur /= 5; } reverse(u.begin(), u.end()); v[x] = u; // print_vector(u); } vector cnt(mx+1); for(int i = 0; i < n; i++) { cnt[to_int(s[i])]++; } for(int i = 0; i < k; i++){ for(int x = mx; x >= 0; x--){ if(v[x][i] == 4) continue; auto u = v[x]; u[i]++; int pre = to_int(u); cnt[x] += cnt[pre]; } } int ans = 0; for(int i = 0; i < n; i++){ if(cnt[to_int(s[i])] > 1) ans++; } cout << ans << endl; }