#ifndef hari64 #include // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define debug(...) #else #include "viewer.hpp" #define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__) #endif // clang-format off using namespace std;constexpr int INF=1001001001;constexpr long long INFll=1001001001001001001; templatebool chmax(T&a,const T&b){return abool chmin(T&a,const T&b){return a>b?a=b,1:0;} // clang-format on int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; set Ss; for (int i = 0; i < N; i++) { string S; cin >> S; Ss.insert(S); } int ans = 0; map memo; auto dfs = [&](const auto &f, string X) -> bool { if (memo.find(X) != memo.end()) return memo[X]; bool has_larger = false; for (int d = 0; d < K; d++) { if (X[d] != '4') { X[d]++; has_larger |= f(f, X); X[d]--; } } // debug(X, has_larger); if (Ss.find(X) != Ss.end()) { if (has_larger) { ans++; } has_larger = true; } return memo[X] = has_larger; }; dfs(dfs, string(K, '0')); cout << ans << endl; return 0; }