#include #include #include #include using namespace std; int main() { // step #1. input int N, K; cin >> N >> K; vector S(N); for (int i = 0; i < N; i++) { cin >> S[i]; } // step #2. compute ID number vector pow6(K + 1); pow6[0] = 1; for (int i = 1; i <= K; i++) { pow6[i] = pow6[i - 1] * 6; } vector id(N); for (int i = 0; i < N; i++) { for (int j = 0; j < K; j++) { id[i] += (int(S[i][j] - '0') + 1) * pow6[j]; } } // step #3. cumulative sum vector sum(pow6[K]); for (int i = 0; i < N; i++) { sum[id[i]] += 1; } for (int i = 0; i < K; i++) { for (int j = 0; j < pow6[K]; j++) { if ((j / pow6[i]) % 6 != 0) { sum[j - pow6[i]] += sum[j]; } } } // step #4. calculate answer int answer = 0; for (int i = 0; i < N; i++) { if (sum[id[i]] >= 2) { answer += 1; } } // step #5. output cout << answer << endl; return 0; }