#include using namespace std; // #include // using namespace atcoder; using ll = long long; const ll MOD = 998'244'353; //const ll MOD = 1000'000'007; const ll INF = (1LL<<30)-1; const ll LINF = (1LL<<62)-1; //#define _GLIBCXX_DEQUE_BUF_SIZE 512 // int:[-2'147'483'648 : 2'147'483'647] // ll:[-9'223'372'036'854'775'808 : 9'223'372'036'854'775'807] #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repi(i, a, n) for (ll i = a; i < (ll)(n); i++) #define pb(a) push_back(a) #define PS(a) cout<<(a)<<" "; #define PL(a) cout<<(a)<; using Pll = pair; template using V = vector; templateostream &operator<<(ostream &os, const vector< T > &v) {for(int i = 0; i < (int) v.size(); i++) {os << v[i] << (i + 1 != (int) v.size() ? " " : "");}return os;} templateistream &operator>>(istream &is, vector< T > &v) {for(T &in : v) is >> in;return is;} template ostream &operator<<(ostream &os, const pair &p) {os << p.first << ' ' << p.second; return os;} template istream &operator>>(istream &is, pair &p) { is >> p.first >> p.second; return is;} template ostream &operator<<(ostream &os, const array< T , sz > &v) {for(int i = 0; i < sz; i++) {os << v[i] << (i + 1 != (int) v.size() ? " " : "");}return os;} template istream &operator>>(istream &is, array< T , sz > &v) {for(T& in:v){cin>>in;} return is;} template void chmin(T& t, const U& u) {if (t > u) t = u;} template void chmax(T& t, const U& u) {if (t < u) t = u;} void solve() { ll N,K; cin>>N>>K; V S(N); cin>>S; rep(i,N) S[i] += string(8-K,'0'); sort(RALL(S)); K = 8; V pos(K); //8 int dp[5][5][5][5][5][5][5][5]; auto dfs = [&](auto dfs, int d)->void { if(d==K){ dp[pos[0]][pos[1]][pos[2]][pos[3]][pos[4]][pos[5]][pos[6]][pos[7]] = 0; return; } rep(i,5){ pos[d] = i; dfs(dfs, d+1); } }; dfs(dfs,0); rep(i,N){ rep(j,K) pos[j] = S[i][j]-'0'; if(dp[pos[0]][pos[1]][pos[2]][pos[3]][pos[4]][pos[5]][pos[6]][pos[7]]==-1) continue; auto dfs2 = [&](auto dfs2, int d)->void { if(d==K){ dp[pos[0]][pos[1]][pos[2]][pos[3]][pos[4]][pos[5]][pos[6]][pos[7]] = -1; return; } for(ll k=S[i][d]-'0';k>=0;k--){ pos[d] = k; dfs2(dfs2, d+1); } }; dfs2(dfs2,0); rep(j,K) pos[j] = S[i][j]-'0'; dp[pos[0]][pos[1]][pos[2]][pos[3]][pos[4]][pos[5]][pos[6]][pos[7]]=1; } ll ans = 0; auto dfs3 = [&](auto dfs3, int d)->void { if(d==K){ if(dp[pos[0]][pos[1]][pos[2]][pos[3]][pos[4]][pos[5]][pos[6]][pos[7]]==1) ans++; return; } rep(i,5){ pos[d] = i; dfs3(dfs3, d+1); } }; dfs3(dfs3,0); PL(N-ans) return; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); int TT = 1; //cin>>TT; for(int tt = 0; tt